This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gold: Something special about malloc/calloc/realloc/free symbols?

Hi all.  I have a weird situation and I don't know what to try next.

I'm creating a .so (on GNU/Linux using GCC 6.2 an binutils 2.27) and I
want to export only a specific set of symbols.  To do this I create a
linker map like this:


and I add it to my link line with -Wl,version-script=...

It all works great, except for one thing.  In my shared library I'm also
linking a memory management library (linked as a .a) which replaces all
the standard memory functions: malloc, calloc, realloc, free.  I don't
want these to be published by my .so because I want only my library to
be able to access them, not a program that links my library.

For some reason in addition to the global symbols I've specified via
global: in the linker map, those four extra symbols are ALSO always

$ nm | grep ' [A-TV-Z] ' | c++filt
0000000000187560 T symbol_one
00000000001862e0 T symbol_two
0000000000166a30 T   ...
00000000008907f0 T calloc
0000000000889ba0 T free
000000000088cb80 T malloc
000000000088e0e0 T realloc

I don't know why this is.  All the other symbols in the source file that
defines the above functions are hidden as I expect, but somehow these
four magically escape the "local" linker script setting and are
published.  I've even tried explicitly listing them as local but that
didn't help.

I'm not sure how that happens, or what I can do about it.  Is there some
extra __attribute__() setting that can be placed on those symbols so
they will ignore my linker script settings?

Any thoughts anyone has on next steps would be welcome.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]