0

To harden my shared library (avoid library injection), I built my shared library with -nostdlib. The shared library depended on a static library (libfreeimage.a) Things went wrong during the linking process:

g++ -shared -fPIC -nostdlib a.o b.o c.o -o libfreeimage.a -o libmy_so.so

the errors were as follows:

/usr/bin/ld: /path/linux_arm64/libfreeimage.a(ImfMultiPartInputFile.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against external 
symbol `__dso_handle' can not be used when making a shared object; recompile with -fPIC
path/linux_arm6/libfreeimage.a(ImfMultiPartInputFile.o):ImfMultiPartInputFile.cpp:(.text.startup+0x110): more undefined refer
ences to `__dso_handle' follow

Were there any gcc flags I have missed, such as -lgcc ?

prgbenz
  • 1,129
  • 4
  • 13
  • 27

0 Answers0