public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/37611]  New: invalid relocation R_386_GOTOFF when using protected function pointers
@ 2008-09-22  7:17 gernot dot hillier at siemens dot com
  2008-09-22  7:20 ` [Bug c/37611] " gernot dot hillier at siemens dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: gernot dot hillier at siemens dot com @ 2008-09-22  7:17 UTC (permalink / raw)
  To: gcc-bugs

When I try to use protected function pointers in a shared library, I experience
strange behaviour: directly passing a function name triggers an invalid
relocation during linking stage while it works when assigning the function name
to a global variable first.

This report might be a duplicate to the old bug 19520, but I'm not sure as my
knowledge about ELF internals is rather limited and I don't understand most of
the discussion there, sorry. If this is a duplicate, please excuse.

Here's the output during compilation. Sources will follow in a few seconds:

$ LANG="" gcc -v -save-temps -Wall test2.c -o libtest2.so -shared -fPIC
-fvisibility=hidden
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ./configure --enable-languages=c,c++
Thread model: posix
gcc version 4.3.2 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-o' 'libtest2.so' '-shared'
'-fPIC' '-fvisibility=hidden' '-mtune=generic'
 /usr/local/libexec/gcc/i686-pc-linux-gnu/4.3.2/cc1 -E -quiet -v test2.c
-mtune=generic -Wall -fPIC -fvisibility=hidden -fpch-preprocess -o test2.i
ignoring nonexistent directory
"/usr/local/lib/gcc/i686-pc-linux-gnu/4.3.2/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/lib/gcc/i686-pc-linux-gnu/4.3.2/include
 /usr/local/lib/gcc/i686-pc-linux-gnu/4.3.2/include-fixed
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-o' 'libtest2.so' '-shared'
'-fPIC' '-fvisibility=hidden' '-mtune=generic'
 /usr/local/libexec/gcc/i686-pc-linux-gnu/4.3.2/cc1 -fpreprocessed test2.i
-quiet -dumpbase test2.c -mtune=generic -auxbase test2 -Wall -version -fPIC
-fvisibility=hidden -o test2.s
GNU C (GCC) version 4.3.2 (i686-pc-linux-gnu)
        compiled by GNU C version 4.3.2, GMP version 4.2.2, MPFR version 2.3.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 53913b99eaa90e1de01474d5b5d32b19
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-o' 'libtest2.so' '-shared'
'-fPIC' '-fvisibility=hidden' '-mtune=generic'
 as -V -Qy -o test2.o test2.s
GNU assembler version 2.18.0 (i486-linux-gnu) using BFD version (GNU Binutils
for Ubuntu) 2.18.0.20080103
COMPILER_PATH=/usr/local/libexec/gcc/i686-pc-linux-gnu/4.3.2/:/usr/local/libexec/gcc/i686-pc-linux-gnu/4.3.2/:/usr/local/libexec/gcc/i686-pc-linux-gnu/:/usr/local/lib/gcc/i686-pc-linux-gnu/4.3.2/:/usr/local/lib/gcc/i686-pc-linux-gnu/
LIBRARY_PATH=/usr/local/lib/gcc/i686-pc-linux-gnu/4.3.2/:/usr/local/lib/gcc/i686-pc-linux-gnu/4.3.2/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-o' 'libtest2.so' '-shared'
'-fPIC' '-fvisibility=hidden' '-mtune=generic'
 /usr/local/libexec/gcc/i686-pc-linux-gnu/4.3.2/collect2 --eh-frame-hdr -m
elf_i386 -shared -o libtest2.so /usr/lib/crti.o
/usr/local/lib/gcc/i686-pc-linux-gnu/4.3.2/crtbeginS.o
-L/usr/local/lib/gcc/i686-pc-linux-gnu/4.3.2
-L/usr/local/lib/gcc/i686-pc-linux-gnu/4.3.2/../../.. test2.o -lgcc --as-needed
-lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed
/usr/local/lib/gcc/i686-pc-linux-gnu/4.3.2/crtendS.o /usr/lib/crtn.o
/usr/bin/ld: test2.o: relocation R_386_GOTOFF against protected function `f2'
can not be used when making a shared object
/usr/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status


-- 
           Summary: invalid relocation R_386_GOTOFF when using protected
                    function pointers
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gernot dot hillier at siemens dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37611


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c/37611] invalid relocation R_386_GOTOFF when using protected function pointers
  2008-09-22  7:17 [Bug c/37611] New: invalid relocation R_386_GOTOFF when using protected function pointers gernot dot hillier at siemens dot com
@ 2008-09-22  7:20 ` gernot dot hillier at siemens dot com
  2008-09-22  7:23 ` gernot dot hillier at siemens dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: gernot dot hillier at siemens dot com @ 2008-09-22  7:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from gernot dot hillier at siemens dot com  2008-09-22 07:19 -------
Created an attachment (id=16375)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16375&action=view)
C file showing the problem

See the body of f1 for the two cases. Using "f3( f2)" triggers the problem
while "f3 (x)" works.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37611


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c/37611] invalid relocation R_386_GOTOFF when using protected function pointers
  2008-09-22  7:17 [Bug c/37611] New: invalid relocation R_386_GOTOFF when using protected function pointers gernot dot hillier at siemens dot com
  2008-09-22  7:20 ` [Bug c/37611] " gernot dot hillier at siemens dot com
@ 2008-09-22  7:23 ` gernot dot hillier at siemens dot com
  2010-01-06 21:01 ` [Bug target/37611] " 3b87w8mt2n at snkmail dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: gernot dot hillier at siemens dot com @ 2008-09-22  7:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from gernot dot hillier at siemens dot com  2008-09-22 07:21 -------
Created an attachment (id=16376)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16376&action=view)
preprocessed version of the code triggering the bug


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37611


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/37611] invalid relocation R_386_GOTOFF when using protected function pointers
  2008-09-22  7:17 [Bug c/37611] New: invalid relocation R_386_GOTOFF when using protected function pointers gernot dot hillier at siemens dot com
  2008-09-22  7:20 ` [Bug c/37611] " gernot dot hillier at siemens dot com
  2008-09-22  7:23 ` gernot dot hillier at siemens dot com
@ 2010-01-06 21:01 ` 3b87w8mt2n at snkmail dot com
  2010-01-06 21:27 ` 3b87w8mt2n at snkmail dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: 3b87w8mt2n at snkmail dot com @ 2010-01-06 21:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from 3b87w8mt2n at snkmail dot com  2010-01-06 21:01 -------
As a data point, this occurs for me with GCC 4.3.4 (Debian 4.3.4-6) on AMD64
(x86_64), compiling the given test file as C:

$ gcc -c -o test2.o test2.c && gcc -shared -o test2.so test2.o
/usr/bin/ld: test2.o: relocation R_X86_64_32 against `f2' can not be used when
making a shared object; recompile with -fPIC
test2.o: could not read symbols: Bad value
collect2: ld returned 1 exit status


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37611


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/37611] invalid relocation R_386_GOTOFF when using protected function pointers
  2008-09-22  7:17 [Bug c/37611] New: invalid relocation R_386_GOTOFF when using protected function pointers gernot dot hillier at siemens dot com
                   ` (2 preceding siblings ...)
  2010-01-06 21:01 ` [Bug target/37611] " 3b87w8mt2n at snkmail dot com
@ 2010-01-06 21:27 ` 3b87w8mt2n at snkmail dot com
  2010-01-06 23:27 ` hjl dot tools at gmail dot com
  2010-05-17 13:50 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: 3b87w8mt2n at snkmail dot com @ 2010-01-06 21:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from 3b87w8mt2n at snkmail dot com  2010-01-06 21:27 -------
Er, sorry, that's the message from the wrong run.  Here's the right one:

$ gcc -fPIC -c -o test2.o test2.c && gcc -shared -o test2.so test2.o
/usr/bin/ld: test2.o: relocation R_X86_64_PC32 against protected symbol `f2'
can not be used when making a shared object
/usr/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37611


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/37611] invalid relocation R_386_GOTOFF when using protected function pointers
  2008-09-22  7:17 [Bug c/37611] New: invalid relocation R_386_GOTOFF when using protected function pointers gernot dot hillier at siemens dot com
                   ` (3 preceding siblings ...)
  2010-01-06 21:27 ` 3b87w8mt2n at snkmail dot com
@ 2010-01-06 23:27 ` hjl dot tools at gmail dot com
  2010-05-17 13:50 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: hjl dot tools at gmail dot com @ 2010-01-06 23:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from hjl dot tools at gmail dot com  2010-01-06 23:27 -------
Function pointer != function address in shared library.
"f2" is protected and the one defined in shared library
will be called. But its function pointer can be out
side of shared library. That is why R_X86_64_PC32
can't be used.

This bug can be fixed if PR 35513 is resolved.


-- 

hjl dot tools at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |35513


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37611


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/37611] invalid relocation R_386_GOTOFF when using protected function pointers
  2008-09-22  7:17 [Bug c/37611] New: invalid relocation R_386_GOTOFF when using protected function pointers gernot dot hillier at siemens dot com
                   ` (4 preceding siblings ...)
  2010-01-06 23:27 ` hjl dot tools at gmail dot com
@ 2010-05-17 13:50 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-05-17 13:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pinskia at gcc dot gnu dot org  2010-05-17 13:49 -------
*** Bug 44166 has been marked as a duplicate of this bug. ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jay dot krell at cornell dot
                   |                            |edu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37611


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-05-17 13:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-22  7:17 [Bug c/37611] New: invalid relocation R_386_GOTOFF when using protected function pointers gernot dot hillier at siemens dot com
2008-09-22  7:20 ` [Bug c/37611] " gernot dot hillier at siemens dot com
2008-09-22  7:23 ` gernot dot hillier at siemens dot com
2010-01-06 21:01 ` [Bug target/37611] " 3b87w8mt2n at snkmail dot com
2010-01-06 21:27 ` 3b87w8mt2n at snkmail dot com
2010-01-06 23:27 ` hjl dot tools at gmail dot com
2010-05-17 13:50 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).