Skip to content

[Arch Linux] Compile error: undefined reference to `dwarf_loclist' #58

Open

Description

@irth

Hi, I'm trying to compile dtrace on my Arch Linux x86_64 (kernel 3.9.9-1-ARCH)
But i'm getting a compile error:

../../build/ctfconvert.obj/dwarf.o: In function `die_mem_offset':
/tmp/dtrace/cmd/ctfconvert/dwarf.c:580: undefined reference to `dwarf_loclist'

/tmp/dtrace-bug.1197.txt: http://ix.io/6xY

Activity

  1. dtrace4linux commented on Jul 7, 2013

    @dtrace4linux
    Owner

    Hello Wojciech

    it looks like dtrace is detecting an incorrect libdw.a shlib on your system
    which doesnt have all the API entry points. for now you can just do a "make
    -i" and ignore the ctfdump/ctfconvert tools which wont get built.

    On 7 July 2013 18:58, Wojciech Kwolek notifications@github.com wrote:

    Hi, i'm trying to compile dtrace on my Arch Linux x86_64 (kernel
    3.9.9-1-ARCH)
    But i'm getting compile error:

    ../../build/ctfconvert.obj/dwarf.o: In function die_mem_offset':
    /tmp/dtrace/cmd/ctfconvert/dwarf.c:580: undefined reference to
    dwarf_loclist'

    /tmp/dtrace-bug.1197.txt: http://ix.io/6xY

    I had also this problem: http://ix.io/6xX, but I solved it by installing
    gcc-multilib.

    Sorry for my English, I'm from Poland, and I dont know English very well...

    —
    Reply to this email directly or view it on GitHubhttps://github.com//issues/58
    .

  2. irth commented on Jul 8, 2013

    @irth
    Author

    libdwarf was installed from Arch User Repository.
    I tried make -i all, but when I try to load modules:
    sudo make load
    I'm getting:
    /tmp/dtrace$ sudo make load tools/load.pl 19:12:51 Syncing... 19:12:51 Loading: build-3.9.9-1-ARCH/driver/dtracedrv.ko insmod: ERROR: could not load module build-3.9.9-1-ARCH/driver/dtracedrv.ko: No such file or directory /proc/dtrace does not exist. Maybe the driver didnt load properly. make: *** [load] Error 1

  3. reopened this on Jul 8, 2013
  4. rendaw commented on Jul 11, 2013

    @rendaw

    It looks like libdw is included by default on Arch but doesn't include the dwarf_loclist symbol. If you install libdwarf through AUR tools/mkport.pl still finds libdw (around line 335). I just deleted some lines to force libdwarf over libdw.

    I didn't hit the compile issue until I installed libdwarf through AUR. If you don't install libdwarf, does the build disable some features or something? I'm not too familiar with the build process.

  5. rendaw commented on Jul 13, 2013

    @rendaw

    Without libdwarf, it appears that the ctfdump/convert stuff is disabled. libdw is installed by default with elfutils.

    With libdwarf (from AUR), mkctf.sh fails:

    tools/mkctf.sh
    ERROR: ctfconvert: die 901: failed to get mem offset location list
    ls: cannot access build/linux-3.9.9-1-ARCH.ctf: No such file or directory
    

    There's some discussion on the AUR page about upstream issues, but I'm not sure it's relevant.

  6. dtrace4linux commented on Jul 13, 2013

    @dtrace4linux
    Owner

    Strange - i took the latest arch download, loaded the deps from the
    tools/get-deps-arch script and it built without problem. I need to look at
    the libdw vs libdwarf issue - I made changes a while back to be
    accomodating of either but it was a dead end - and its annoying. I want to
    reexamine ctfdump to see what I could do to omit the dependency. Its
    annoying that there are two standard interfaces and not easily
    interchangeable.

    for now - it mostly doesnt matter - it just means the linux.ctf file is
    useless - most people wont care. its only needed for struct member
    references in D scripts.

    On 13 July 2013 07:26, Rendaw notifications@github.com wrote:

    Without libdwarf, it appears that the ctfdump/convert stuff is disabled.
    libdw is installed by default with elftools.

    With libdwarf (from AUR), mkctf.sh fails:

    tools/mkctf.sh
    ERROR: ctfconvert: die 901: failed to get mem offset location list
    ls: cannot access build/linux-3.9.9-1-ARCH.ctf: No such file or directory

    There's some discussion on the AUR page about upstream issues, but I'm not
    sure it's relevant.

    —
    Reply to this email directly or view it on GitHubhttps://github.com//issues/58#issuecomment-20915553
    .

  7. rendaw commented on Jul 13, 2013

    @rendaw

    I just tried get-deps-arch but I already had all the dependencies and "make all" still didn't build the ctf utils.

    To be perfectly honest I've never used dtrace before but it sounded exciting so I wanted to try it. I don't do any D but if you want to get it working and there's any tests/information you need I'd be glad to help.

    It seems like with a little work libdw and libdwarf are both available on arch. Are the other distros similar? If it's easier to just support one I think people would be willing to put in a little effort to get whichever dependency is needed.

  8. dtrace4linux commented on Jul 13, 2013

    @dtrace4linux
    Owner

    If you do "make -i all" then you are good to go - next do:
    $ make load
    $ sudo build/dtrace -n syscall:::

    and you can see all the syscalls on the system (a lot!) You can fine tune,
    e.g.

    $ sudo build/dtrace -n syscall::open*:'{printf("%s", execname);}'

    to see the executables opening files.

    libdwarf is the better - but there are lots of versions of this and i was
    trying to support all the older systems, so its not so clear cut. My code
    is looking to see if libdw and libdwarf is installed and then (probably)
    picking the wrong one. When I ran this last night - it was a clean build -
    so you likely have both installed and I dont (or I even have neither!)

    On 13 July 2013 11:11, Rendaw notifications@github.com wrote:

    I just tried get-deps-arch but I already had all the dependencies and
    "make all" still didn't build the ctf utils.

    To be perfectly honest I've never used dtrace before but it sounded
    exciting so I wanted to try it. I don't do any D but if you want to get it
    working and there's any tests/information you need I'd be glad to help.

    It seems like with a little work libdw and libdwarf are both available on
    arch. Are the other distros similar? If it's easier to just support one I
    think people would be willing to put in a little effort to get whichever
    dependency is needed.

    —
    Reply to this email directly or view it on GitHubhttps://github.com//issues/58#issuecomment-20917773
    .

  9. rendaw commented on Jul 13, 2013

    @rendaw

    Ok, thanks for the intro! I'll try that out.

  10. ryao commented on Mar 6, 2014

    @ryao
    Contributor

    I can reproduce this on Gentoo Linux with the following commands:

    # Note that layman must be installed and setup first
    layman -a ikelos
    echo dev-libs/libdwarf ~amd64 >> /etc/portage/package.accept_keywords
    wget 'https://launchpad.net/ubuntu/+archive/primary/+files/dwarfutils_20120410.orig.tar.gz' -O /usr/portage/distfiles/libdwarf-20120410.tar.gz
    emerge dev-libs/libdwarf
    git checkout git://github.com/dtrace4linux/linux.git
    cd linux
    make all
    

    It seems that the problem is that the check for libdwarf in tools/mkport.pl is broken. The check will never select libdwarf. Modifying tools/mkport.pl to force libdwarf to be used allows things to work.

    As for libelf, this appears to be the commit that broke compatibility:

    https://git.fedorahosted.org/cgit/elfutils.git/commit/?id=0cf762c2d960cd64e72d8637db0c38102bd6a4ee

  11. dtrace4linux commented on Mar 6, 2014

    @dtrace4linux
    Owner

    Thanks for attempting to locate the broken commit. The state of ELF is
    forever broken on all kernels because of the horrible history of the two
    dwarf libraries. I have given up trying to salvage the horrible nature of
    the mess. Its a shame because the owner of libdwarf has done a good job,
    but the horrible state of all distros and trying to cater for both ELF
    libraries - you can have either or both installed, is really painful.

    My next attempt to fix and remove this is to avoid libdwarf and use the
    readelf tool instead.

    The situation is so bad, because I am always confused whether libdwarf or
    libdw is the latest conformant implementation. I have looked at the
    implementation of dwarf_loclist but it doesnt help - I tried to create a
    portable layer between the two libs but abandoned it due to the "just one
    more API needs to be grafted" onboard.

    I may take another look (using readelf - or any other tool which works)
    since I am now going to look at another kernel bug/issue on ubuntu 12.04.

    On 6 March 2014 02:38, Richard Yao notifications@github.com wrote:

    Well, it seems that a link with libdw from elfutils is attempted when
    libdwarf is installed. Anyway, this is the commit that broke compatibility:

    https://git.fedorahosted.org/cgit/elfutils.git/commit/?id=0cf762c2d960cd64e72d8637db0c38102bd6a4ee

    Removing libdwarf and downgrading to dev-libs/elfutils-0.148 does not fix
    things. We just have a different failure there.

    Executing: /home/richard/devel/dtrace/tools/make-me
    make -C /lib/modules/3.12.6/build M=/home/richard/devel/dtrace/build-3.12.6/driver
    make[2]: *** No targets specified and no makefile found. Stop.
    make[1]: *** [kernel] Error 2

    Reply to this email directly or view it on GitHubhttps://github.com//issues/58#issuecomment-36819349
    .

  12. gaojx commented on Oct 17, 2014

    @gaojx

    I got the same comiple error on centos:
    /mnt/disk1/home/gaojx/dtrace/linux/cmd/ctfconvert/dwarf.c:581: undefined reference to `dwarf_loclist'

    After command: make -i all, command: dtrace load gives:

  13. gaojx commented on Oct 17, 2014

    @gaojx

    Sorry, the comment was cut off. Continue last comment:

    dtrace: failed to initialize dtrace: DTrace device not available on system

    I have the lastest libdwarf installed (from git://libdwarf.git.sourceforge.net/gitroot/libdwarf/libdwarf).

    What is natural of this error? I am willing to take a look at the code if you can give me some guideline. We have an important issue that needs dtrace to help out, so significant effort can be devoted to make this work. Any help will be highly appreciated.

  14. dtrace4linux commented on Oct 17, 2014

    @dtrace4linux
    Owner

    You need to read my blog where I have repeatedly discussed this. There are
    two incompatible libdwarf libraries out there. dtrace uses one and some
    distros deploy the other. I have looked at the dwarf_loclist issue before -
    getting ones mind around libdwarf and two competing libraries is harmful to
    the brain :-) Since this issue keeps coming up, I need to look again.
    (libdwarf vs libdw). One option is to package libdw/dwarf with dtrace but
    am loathe to do that. Let me take a look.

    On 17 October 2014 22:24, gaojx notifications@github.com wrote:

    Sorry, the comment was cut off. Continue last comment:

    dtrace: failed to initialize dtrace: DTrace device not available on system

    I have the lastest libdwarf installed (from git://
    libdwarf.git.sourceforge.net/gitroot/libdwarf/libdwarf).

    What is natural of this error? I am willing to take a look at the code if
    you can give me some guideline. We have an important issue that needs
    dtrace to help out, so significant effort can be devoted to make this work.
    Any help will be highly appreciated.

    —
    Reply to this email directly or view it on GitHub
    #58 (comment).

  15. gaojx commented on Oct 20, 2014

    @gaojx

    Thanks for the reply, from which I downloaded and installed the other libdwarf (from github, my first one comes from soureforge). Lo and behold, it builds successfully. make install and make load also runs without issue. Good progress.

    However, make test crashes the kernel:
    20141020 10:40:07 Test: fbt-a
    build/dtrace -n ' BEGIN {
    tstart = timestamp;
    }
    fbt::a*:
    {
    cnt++;
    }
    tick-1ms /timestamp - tstart > 5 * 1000 * 1000 * 1000 / {exit(0);}
    tick-1s { printf("count so far: %d", cnt); }
    tick-5s { exit(0); }
    ' >/tmp/test-root.fbt-a.log 2>&1
    20141020 10:40:07 === Test: fbt-a
    -> the system freeze here.

    One thing I noticed during the compile:
    dtrace/linux/build-2.6.32-431.17.1.el6.x86_64/driver/x_call.c:96:3: warning: #warning "NCPU is large - your module may not load (x_call.c)"

    I changed the code to print out the value of NCPU:

    #define STRING2(x) #x
    #define STRING(x) STRING2(x)
    #pragam message "NCPU = " STRING(NCPU)

    It prints out: NCPU=496

    My linux machine has only 4 cores. In the Changes file:
    691* x_call.c: Put in a warning if NCPU is too large - can cause
    problems at driver load time (Centos 6.2 has NCPU==4096 which
    equates to more than 40MB of memory for the xcall array).

    Would this be issue that causes the crash?

  16. gaojx commented on Oct 20, 2014

    @gaojx

    A typo correction: the print out for NCPU is: NCPU = 4096.

    My centos version: 6.5, linux kernel: 2.6.32-431, x86_64

    What does NCPU mean? If it is # of cores on the system, should it be 4 in my case?

  17. dtrace4linux commented on Oct 20, 2014

    @dtrace4linux
    Owner

    Great you got it working. No the ncpu issue isn't the cause of your crash.
    It's one of the matching kernel routines...maybe reentrancy. Will need to
    look.
    On 20 Oct 2014 16:00, "gaojx" notifications@github.com wrote:

    Thanks for the reply, from which I downloaded and installed the other
    libdwarf (from github, my first one comes from soureforge). Lo and behold,
    it builds successfully. make install and make load also runs without issue.
    Good progress.

    However, make test crashes the kernel:
    20141020 10:40:07 Test: fbt-a
    build/dtrace -n ' BEGIN {
    tstart = timestamp;
    }
    fbt::a*:
    {
    cnt++;
    }
    tick-1ms /timestamp - tstart > 5 * 1000 * 1000 * 1000 / {exit(0);}
    tick-1s { printf("count so far: %d", cnt); }
    tick-5s { exit(0); }
    ' >/tmp/test-root.fbt-a.log 2>&1
    20141020 10:40:07 === Test: fbt-a
    -> the system freeze here.

    One thing I noticed during the compile:
    dtrace/linux/build-2.6.32-431.17.1.el6.x86_64/driver/x_call.c:96:3:
    warning: #warning "NCPU is large - your module may not load (x_call.c)"

    I changed the code to print out the value of NCPU:

    #define STRING2(x) #x
    #define STRING(x) STRING2(x)
    #pragam message "NCPU = " STRING(NCPU)

    It prints out: NCPU=496

    My linux machine has only 4 cores. In the Changes file:
    691* x_call.c: Put in a warning if NCPU is too large - can cause
    problems at driver load time (Centos 6.2 has NCPU==4096 which
    equates to more than 40MB of memory for the xcall array).

    Would this be issue that causes the crash?

    —
    Reply to this email directly or view it on GitHub
    #58 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions