Bug 32434 - #pragma GCC visibility causes invalid relocation to __stach_chk_guard
Summary: #pragma GCC visibility causes invalid relocation to __stach_chk_guard
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.1.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Keywords: visibility
Depends on: 20297
Blocks: visibility
  Show dependency treegraph
Reported: 2007-06-20 17:48 UTC by David Lamparter
Modified: 2021-09-17 00:10 UTC (History)
1 user (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed:

Test source (168 bytes, application/octet-stream)
2007-06-20 17:50 UTC, David Lamparter
Script for compiling test.c with different flags (182 bytes, application/x-sh)
2007-06-20 17:51 UTC, David Lamparter

Note You need to log in before you can comment on or make changes to this bug.
Description David Lamparter 2007-06-20 17:48:28 UTC
When using, e.g., #pragma GCC visibility push(internal) together with -fstack-protector and PIC code, gcc emits an invalid R_386_GOTOFF relocation to __stack_chk_guard.

(Testcase follows)

Note that the problem does not happen with -fvisibility, __attribute__((visibility)) or when there is a reference to __stack_chk_guard before the #pragma.
Comment 1 David Lamparter 2007-06-20 17:50:06 UTC
Created attachment 13748 [details]
Test source

Try with different flags as shown in test.sh
Comment 2 David Lamparter 2007-06-20 17:51:12 UTC
Created attachment 13749 [details]
Script for compiling test.c with different flags

# sh ./test.sh
-fno-stack-protector : 
-fno-stack-protector -fvisibility=internal: 
-fno-stack-protector -DVIS_ATTR: 
-fno-stack-protector -DVIS_PRAGMA: 
-fno-stack-protector -DVIS_PRAGMA -DREF_BEFORE: 
-fstack-protector-all : 
-fstack-protector-all -fvisibility=internal: 
-fstack-protector-all -DVIS_ATTR: 
-fstack-protector-all -DVIS_PRAGMA: 
/usr/lib/gcc/i686-colt-linux-gnu/4.1.2/../../../../i686-colt-linux-gnu/bin/ld: /tmp/ccHCfgCk.o(.text+0x14): unresolvable relocation against symbol `__stack_chk_guard@@LIBSSP_1.0'
/usr/lib/gcc/i686-colt-linux-gnu/4.1.2/../../../../i686-colt-linux-gnu/bin/ld: final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status
-fstack-protector-all -DVIS_PRAGMA -DREF_BEFORE:
Comment 3 David Lamparter 2007-06-20 17:54:19 UTC
# gcc -v
Using built-in specs.
Target: i686-colt-linux-gnu
Configured with: ../gcc-4.1.2/configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --build=i686-colt-linux-gnu --host=i686-colt-linux-gnu --target=i686-colt-linux-gnu --enable-libssp --enable-shared --enable-__cxa_atexit --enable-threads=posix --libexecdir=/usr/lib --enable-clocale --enable-languages=c,c++,objc,obj-c++ --enable-multilib=no
Thread model: posix
gcc version 4.1.2
# uname -a
Linux neptune 2.6.22-rc4 #19 PREEMPT Sat Jun 9 18:51:59 CEST 2007 i686 athlon-4 i386 GNU/Linux
# /lib/libc.so.6 | grep 'GNU C'
GNU C Library stable release version 2.3.6, by Roland McGrath et al.
Compiled by GNU CC version 4.1.0 colt stage0.

cmdline / output see test.sh.
Comment 4 Andrew Pinski 2007-06-20 20:53:35 UTC
Related to PR 20297.