I have recently been reading up on linkers and I'm having trouble understanding this compilation code. If I were to run gcc -Wl,--hash-style=both example.c
, what difference will it make as opposed to me simply running gcc example.c
. And also, what does --hash-style
means

- 173
- 2
- 12
1 Answers
what does
--hash-style
means
--hash-style
allows you to change the format of hashtable which is used for runtime symbol resolution (see Drepper's article, section "The GNU-style Hash Table" for details). The GNU hashtable format is said to be slightly faster.
If I were to run
gcc -Wl,--hash-style=both example.c
, what difference will it make as opposed to me simply runninggcc example.c
It depends on how your distro's GCC was configured. AFAIK most use either both
or gnu
styles by default. Both
simply means that linked files will include, um, both gnu
and sysv
hashtables. This shouldn't matter unless you try to run your program on a system with dynamic linker which does not understand GNU hashtables. In that case, if program was built with -Wl,--hash-style=gnu
, you'll get an error at startup about unsupported hashtable format.

- 19,769
- 3
- 51
- 96
-
1Can you give an example for "system with dynamic linker which does not understand GNU hashtables"? – Kiril Kirov Mar 10 '17 at 09:41
-
@KirilKirov I can't point to concrete distro/revision but people [do report about such systems](http://stackoverflow.com/questions/39132507/compile-libstdc-with-hash-style-sysv). – yugr Mar 10 '17 at 15:43