https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111936

--- Comment #5 from vincenzo Innocente <vincenzo.innocente at cern dot ch> ---
My bad, long time I'm not using archive libraries and forgot about the order
rule. 

The issue is indeed missing -fPIC.
Thanks for the fast action.

I applied the patch but it seems not sufficient.

If I well understood this is where the ar lib is built
ar  rc .libs/libstdc++_libbacktrace.a  std_stacktrace-atomic.o
std_stacktrace-backtrace.o std_stacktrace-dwarf.o std_stacktrace-fileline.o
std_stacktrace-posix.o std_stacktrace-sort.o std_stacktrace-simple.o std_sta
cktrace-state.o std_stacktrace-cp-demangle.o std_stacktrace-elf.o
std_stacktrace-mmapio.o std_stacktrace-mmap.o

but those are the file compiled w/o -fPIC
those with fPIC are under .libs itself...

so I did manually
```
ar rc .libs/libstdc++_libbacktrace.a .libs/*.o ../c++23/stacktrace.o

```

and then locally
c++ -O3 -pthread -fPIC -shared -std=c++23 getStacktrace.cc
/data/user/innocent/gcc_build/x86_64-pc-linux-gnu/libstdc++-v3/src/libbacktrace/.libs/libstdc++_libbacktrace.a
-g -o mallocHook.so


and runs
setenv LD_PRELOAD ./mallocHook.so ; ./a.out ; unsetenv LD_PRELOAD
asked 4 at ###std::__new_allocator<int>::allocate(unsigned long, void
const*)#std::allocator_traits<std::allocator<int>
>::allocate(std::allocator<int>&, unsigned long)#void std::vector<int,
std::allocator<int> >::_M_realloc_insert<int
const&>(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int>
> >, int const&)#std::vector<int, std::allocator<int> >::push_back(int
const&)#go(int)#main##_start##
asked 8 at ###std::__new_allocator<int>::allocate(unsigned long, void
const*)#std::allocator_traits<std::allocator<int>
>::allocate(std::allocator<int>&, unsigned long)#void std::vector<int,
std::allocator<int> >::_M_realloc_insert<int
const&>(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int>
> >, int const&)#std::vector<int, std::allocator<int> >::push_back(int
const&)#go(int)#main##_start##
asked 16 at ###std::__new_allocator<int>::allocate(unsigned long, void
const*)#std::allocator_traits<std::allocator<int>
>::allocate(std::allocator<int>&, unsigned long)#void std::vector<int,
std::allocator<int> >::_M_realloc_insert<int
const&>(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int>
> >, int const&)#std::vector<int, std::allocator<int> >::push_back(int
const&)#go(int)#main##_start##
asked 32 at ###std::__new_allocator<int>::allocate(unsigned long, void
const*)#std::allocator_traits<std::allocator<int>
>::allocate(std::allocator<int>&, unsigned long)#void std::vector<int,
std::allocator<int> >::_M_realloc_insert<int
const&>(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int>
> >, int const&)#std::vector<int, std::allocator<int> >::push_back(int
const&)#go(int)#main##_start##
asked 64 at ###std::__new_allocator<int>::allocate(unsigned long, void
const*)#std::allocator_traits<std::allocator<int>
>::allocate(std::allocator<int>&, unsigned long)#void std::vector<int,
std::allocator<int> >::_M_realloc_insert<int
const&>(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int>
> >, int const&)#std::vector<int, std::allocator<int> >::push_back(int
const&)#go(int)#main##_start##
asked 128 at ###std::__new_allocator<int>::allocate(unsigned long, void
const*)#std::allocator_traits<std::allocator<int>
>::allocate(std::allocator<int>&, unsigned long)#void std::vector<int,
std::allocator<int> >::_M_realloc_insert<int
const&>(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int>
> >, int const&)#std::vector<int, std::allocator<int> >::push_back(int
const&)#go(int)#main##_start##
asked 256 at ###std::__new_allocator<int>::allocate(unsigned long, void
const*)#std::allocator_traits<std::allocator<int>
>::allocate(std::allocator<int>&, unsigned long)#void std::vector<int,
std::allocator<int> >::_M_realloc_insert<int
const&>(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int>
> >, int const&)#std::vector<int, std::allocator<int> >::push_back(int
const&)#go(int)#main##_start##
asked 512 at ###std::__new_allocator<int>::allocate(unsigned long, void
const*)#std::allocator_traits<std::allocator<int>
>::allocate(std::allocator<int>&, unsigned long)#void std::vector<int,
std::allocator<int> >::_M_realloc_insert<int
const&>(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int>
> >, int const&)#std::vector<int, std::allocator<int> >::push_back(int
const&)#go(int)#main##_start##

Reply via email to