Skip to content

undefined reference to __glibc_unlikely #41

Description

@milahu

libelfmaster fails to compile with musl

gcc -I ./ -static shiva.o shiva_util.o shiva_signal.o shiva_ulexec.o shiva_auxv.o shiva_module.o shiva_trace.o shiva_trace_thread.o shiva_error.o shiva_maps.o shiva_analyze.o shiva_callsite.o shiva_target.o shiva_xref.o shiva_transform.o shiva_so.o shiva_post_linker.o /nix/store/rl8bajlymj1md1000f91gjhnvz0nrpwq-libelfmaster-0.4-alpha-unstable-2023-02-23/lib/libelfmaster.a /nix/store/jagvcafr5xbnriwg6xajw2brvcjxcwi1-capstone-4.0.2/lib/libcapstone.a -o './build'/shiva
/nix/store/a1kgwwyad44q620sym78yx5cwprgwqgs-binutils-2.40/bin/ld: /nix/store/rl8bajlymj1md1000f91gjhnvz0nrpwq-libelfmaster-0.4-alpha-unstable-2023-02-23/lib/libelfmaster.a(libelfmaster.o): in function `elf_scop_text_filesz':
(.text+0x3314): undefined reference to `__glibc_unlikely'

fix

    # fix: undefined reference to `__glibc_unlikely'
    #define __glibc_unlikely(cond) __builtin_expect ((cond), 0)
    substituteInPlace include/libelfmaster.h \
      --replace-fail \
        '#define peu_probable __glibc_unlikely' \
        '#define peu_probable(cond) __builtin_expect ((cond), 0)' \
$ grep -r -w __glibc_unlikely libelfmaster/
libelfmaster/include/libelfmaster.h:#define peu_probable __glibc_unlikely

based on gear-lib/gear-lib/libdebug/gcc.macro

#define __glibc_unlikely(cond) __builtin_expect ((cond), 0)

Activity

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