Bug 27998 - relocation R_386_GOTOFF against STT_GNU_IFUNC symbol `foo' isn't supported
Summary: relocation R_386_GOTOFF against STT_GNU_IFUNC symbol `foo' isn't supported
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.37
: P2 normal
Target Milestone: 2.37
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-06-20 02:29 UTC by H.J. Lu
Modified: 2021-06-20 18:53 UTC (History)
0 users

See Also:
Host:
Target: i386
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2021-06-20 02:29:43 UTC
[hjl@gnu-tgl-2 pr83782]$ cat test.s
	.text
	.p2align 4
	.type	my_foo, @function
my_foo:
	ret
	.size	my_foo, .-my_foo
	.p2align 4
	.type	resolve_foo, @function
resolve_foo:
	leal	my_foo@GOTOFF(%eax), %eax
	ret
	.size	resolve_foo, .-resolve_foo
	.type	foo, @gnu_indirect_function
	.set	foo,resolve_foo
	.p2align 4
	.globl	bar
	.type	bar, @function
bar:
	leal	foo@GOTOFF(%eax), %eax
	ret
[hjl@gnu-tgl-2 pr83782]$ gcc -m32 -c test.s
[hjl@gnu-tgl-2 pr83782]$ ld -m elf_i386 -o libtest.so  -shared test.o
ld: test.o: relocation R_386_GOTOFF against STT_GNU_IFUNC symbol `foo' isn't supported
ld: final link failed: bad value
[hjl@gnu-tgl-2 pr83782]$
Comment 1 cvs-commit@gcc.gnu.org 2021-06-20 03:21:38 UTC
The master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=406b4ada55b2957c10fedaeaada801e77912d976

commit 406b4ada55b2957c10fedaeaada801e77912d976
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sat Jun 19 20:20:52 2021 -0700

    x86: Count PLT for GOTOFF relocation against IFUNC symbol
    
    Since GOTOFF relocations against IFUNC symbols must go through PLT,
    set PLT reference count to 1 for GOTOFF relocation.
    
    bfd/
    
            PR ld/27998
            * elfxx-x86.c (elf_x86_allocate_dynrelocs): Count PLT for GOTOFF
            relocation against IFUNC symbols.
            (_bfd_x86_elf_adjust_dynamic_symbol): Likewise.
    
    ld/
    
            PR ld/27998
            * testsuite/ld-i386/i386.exp: Run PR ld/27998 tests.
            * testsuite/ld-i386/pr27998a.d: New file.
            * testsuite/ld-i386/pr27998a.s: Likewise.
            * testsuite/ld-i386/pr27998b.d: Likewise.
            * testsuite/ld-i386/pr27998b.s: Likewise.
Comment 2 H.J. Lu 2021-06-20 18:53:40 UTC
Fixed for 2.37.