Bug 28870 - relocation R_386_GOT32 against absolute symbol is disallowed
Summary: relocation R_386_GOT32 against absolute symbol is disallowed
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.39
: P2 normal
Target Milestone: 2.38
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-02-07 22:58 UTC by H.J. Lu
Modified: 2022-02-08 00:20 UTC (History)
1 user (show)

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 2022-02-07 22:58:38 UTC
[hjl@gnu-tgl-3 tmp]$ cat foo.s
	.text
	.globl _start
_start:
	cmpl	$0, _nl_current_LC_COLLATE_used@GOT(%ebx)
	_nl_current_LC_COLLATE_used = 2
[hjl@gnu-tgl-3 tmp]$ gcc -c foo.s -m32    
[hjl@gnu-tgl-3 tmp]$ ld -pie foo.o -m elf_i386  
ld: foo.o: relocation R_386_GOT32 against absolute symbol `_nl_current_LC_COLLATE_used' in section `.text' is disallowed
[hjl@gnu-tgl-3 tmp]$
Comment 1 Sourceware Commits 2022-02-08 00:07:09 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=30a954525f4e53a9cd50a1a8a6f201c7cf6595c7

commit 30a954525f4e53a9cd50a1a8a6f201c7cf6595c7
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Feb 7 15:22:19 2022 -0800

    i386: Allow GOT32 relocations against ABS symbols
    
    GOT32 relocations are allowed since absolute value + addend is stored in
    the GOT slot.
    
    Tested on glibc 2.35 build with GCC 11.2 and -Os.
    
    bfd/
    
            PR ld/28870
            * elfxx-x86.c (_bfd_elf_x86_valid_reloc_p): Also allow GOT32
            relocations.
    
    ld/
    
            PR ld/28870
            * testsuite/ld-i386/i386.exp: Run pr28870.
            * testsuite/ld-i386/pr28870.d: New file.
            * testsuite/ld-i386/pr28870.s: Likewise.
Comment 2 Sourceware Commits 2022-02-08 00:12:48 UTC
The binutils-2_38-branch branch has been updated by H.J. Lu <hjl@sourceware.org>:

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

commit 3cb97931a4728f652d1030edb9eada62d8ccc605
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Feb 7 15:22:19 2022 -0800

    i386: Allow GOT32 relocations against ABS symbols
    
    GOT32 relocations are allowed since absolute value + addend is stored in
    the GOT slot.
    
    Tested on glibc 2.35 build with GCC 11.2 and -Os.
    
    bfd/
    
            PR ld/28870
            * elfxx-x86.c (_bfd_elf_x86_valid_reloc_p): Also allow GOT32
            relocations.
    
    ld/
    
            PR ld/28870
            * testsuite/ld-i386/i386.exp: Run pr28870.
            * testsuite/ld-i386/pr28870.d: New file.
            * testsuite/ld-i386/pr28870.s: Likewise.
    
    (cherry picked from commit 30a954525f4e53a9cd50a1a8a6f201c7cf6595c7)
Comment 3 Sourceware Commits 2022-02-08 00:19:30 UTC
The binutils-2_37-branch branch has been updated by H.J. Lu <hjl@sourceware.org>:

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

commit 7c4b20b9583d0d9c99e0793fd98ed0aaef2af729
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Feb 7 15:22:19 2022 -0800

    i386: Allow GOT32 relocations against ABS symbols
    
    GOT32 relocations are allowed since absolute value + addend is stored in
    the GOT slot.
    
    Tested on glibc 2.35 build with GCC 11.2 and -Os.
    
    bfd/
    
            PR ld/28870
            * elfxx-x86.c (_bfd_elf_x86_valid_reloc_p): Also allow GOT32
            relocations.
    
    ld/
    
            PR ld/28870
            * testsuite/ld-i386/i386.exp: Run pr28870.
            * testsuite/ld-i386/pr28870.d: New file.
            * testsuite/ld-i386/pr28870.s: Likewise.
    
    (cherry picked from commit 30a954525f4e53a9cd50a1a8a6f201c7cf6595c7)
Comment 4 H.J. Lu 2022-02-08 00:20:24 UTC
Fixed for 2.38 and 2.37 branch.