1 From: Rich Felker <dalias@aerifal.cx>
2 Date: Tue, 29 Sep 2015 02:44:05 +0000
3 Subject: [PATCH] eliminate protected-visibility data in libc.so with vis.h
6 some newer binutils versions print scary warnings about protected data
7 because most gcc versions fail to produce the right address
8 references/relocations for such data that might be subject to copy
9 relocations. originally vis.h explicitly assigned default visibility
10 to all public data symbols to avoid this issue, but commit
11 b8dda24fe1caa901a99580f7a52defb95aedb67c removed this treatment for
12 stdin/out/err to work around a gcc 3.x bug, and since they don't
13 actually need it (because taking their addresses is not valid C).
15 instead, a check for the gcc 3.x bug is added to the configure check
16 for vis.h preinclude support; this feature will simply be disabled
17 when using a buggy version of gcc.
22 @@ -476,10 +476,18 @@ if test "x$visibility" = xauto ; then
23 # - the -include option
24 # - the attributes/pragmas used in vis.h
25 # - linking code that takes the address of protected symbols
26 +# - gcc 3.x bug that wrongly claims declarations mismatch
27 printf "checking whether global visibility preinclude works... "
28 -echo 'int (*fp)(void);' > "$tmpc"
29 -echo 'int foo(void) { }' >> "$tmpc"
30 -echo 'int bar(void) { fp = foo; return foo(); }' >> "$tmpc"
32 +__attribute__((__visibility__("default")))
33 +extern struct a *const x;
39 +int bar(void) { fp = foo; return foo(); }
41 if $CC $CFLAGS_C99FSE $CPPFLAGS $CFLAGS \
42 -DSHARED -fPIC -I./src/internal -include vis.h \
43 -nostdlib -shared -Wl,-Bsymbolic-functions \
44 --- a/src/internal/vis.h
45 +++ b/src/internal/vis.h
47 * exported data symbols. */
49 __attribute__((__visibility__("default")))
50 +extern struct _IO_FILE *const stdin, *const stdout, *const stderr;
52 +__attribute__((__visibility__("default")))
53 extern int optind, opterr, optopt, optreset, __optreset, getdate_err, h_errno, daylight, __daylight, signgam, __signgam;
55 __attribute__((__visibility__("default")))