Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gcc: should install PIC version of libiberty #2083

Open
LionNatsu opened this issue Jan 3, 2020 · 0 comments
Open

gcc: should install PIC version of libiberty #2083

LionNatsu opened this issue Jan 3, 2020 · 0 comments
Labels
core AOSC OS Core related feature-request Request for an AOSC OS feature

Comments

@LionNatsu
Copy link
Member

Now libiberty.a is not available for shared objects unless it was built with PIC. GCC always builds two libiberty.a and we should install the PIC one not the plain static one.

root@stable-40001 [ ~ ] # cat demangle.c
#include <stdio.h>
#include <libiberty/demangle.h>

__attribute__((constructor))
void mian() {
    char *prot = cplus_demangle("_ZN9wikipedia7article6formatEv", DMGL_AUTO);
    puts(prot);
}
root@stable-40001 [ ~ ] # gcc -shared -fPIC demangle.c -o test.so
root@stable-40001 [ ~ ] # load-shlib ./test.so
./test.so: undefined symbol: cplus_demangle
root@stable-40001 [ ~ ] ! gcc -shared -fPIC demangle.c -o test.so -liberty
/bin/ld: error: /usr/lib/gcc/x86_64-aosc-linux-gnu/8.3.1/../../../../lib64/libiberty.a(cplus-dem.o): requires dynamic R_X86_64_PC32 reloc against '_sch_istable' which may overflow at runtime; recompile with -fPIC
/bin/ld: error: /usr/lib/gcc/x86_64-aosc-linux-gnu/8.3.1/../../../../lib64/libiberty.a(cp-demangle.o): requires dynamic R_X86_64_PC32 reloc against 'cplus_demangle_builtin_types' which may overflow at runtime; recompile with -fPIC
/bin/ld: error: /usr/lib/gcc/x86_64-aosc-linux-gnu/8.3.1/../../../../lib64/libiberty.a(d-demangle.o): requires dynamic R_X86_64_PC32 reloc against '_sch_istable' which may overflow at runtime; recompile with -fPIC
/bin/ld: error: /usr/lib/gcc/x86_64-aosc-linux-gnu/8.3.1/../../../../lib64/libiberty.a(xmalloc.o): requires dynamic R_X86_64_PC32 reloc against 'environ' which may overflow at runtime; recompile with -fPIC
/bin/ld: error: /usr/lib/gcc/x86_64-aosc-linux-gnu/8.3.1/../../../../lib64/libiberty.a(xexit.o
): requires dynamic R_X86_64_PC32 reloc against '_xexit_cleanup' which may overflow at runtime; recompile with -fPIC
collect2: error: ld returned 1 exit status

FYI, Arch Linux had the same issue and they fixed it:

@MingcongBai MingcongBai transferred this issue from AOSC-Archive/aosc-os-core Jan 30, 2020
@MingcongBai MingcongBai added core AOSC OS Core related feature-request Request for an AOSC OS feature labels Jan 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core AOSC OS Core related feature-request Request for an AOSC OS feature
Projects
None yet
Development

No branches or pull requests

2 participants