Skip to content

Instantly share code, notes, and snippets.

@rofl0r
Created April 18, 2019 22:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rofl0r/64fb5affb083ac8bcf0ebfaf6c5905e6 to your computer and use it in GitHub Desktop.
Save rofl0r/64fb5affb083ac8bcf0ebfaf6c5905e6 to your computer and use it in GitHub Desktop.
how to produce glibc's odd static linking warning about getaddrinfo
$ cat link_warning.c
#define __sec_comment "\n\t#"
#define __make_section_unallocated(section_string) \
asm (".section " section_string "\n\t.previous");
#define link_warning(symbol, msg) \
__make_section_unallocated (".gnu.warning." #symbol) \
static const char __evoke_link_warning_##symbol[] \
__attribute__ ((used, section (".gnu.warning." #symbol __sec_comment))) \
= msg;
#define static_link_warning(name) static_link_warning1(name)
#define static_link_warning1(name) \
link_warning(name, "Using '" #name "' in statically linked applications \
requires at runtime the shared libraries from the glibc version used \
for linking")
void test (void)
{
}
azanella@birita:/tmp$ cat test-main.c
void test (void);
int main ()
{
test ();
return 0;
}
$ gcc test-main.c -c
$ gcc link_warning.c -c
$ gcc test-main.o link_warning.o -o test-main
test-main.o:test-main.c:function main: warning: Using 'test' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment