Bug 23162 - assertion fail binutils/bfd/elf32-i386.c:3953
Summary: assertion fail binutils/bfd/elf32-i386.c:3953
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.31
: P2 normal
Target Milestone: 2.31
Assignee: H.J. Lu
URL:
Keywords:
Depends on: 23161
Blocks:
  Show dependency treegraph
 
Reported: 2018-05-10 19:18 UTC by H.J. Lu
Modified: 2018-05-14 10:49 UTC (History)
1 user (show)

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


Attachments
A patch (701 bytes, patch)
2018-05-10 20:43 UTC, H.J. Lu
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2018-05-10 19:18:49 UTC
[hjl@gnu-skx-1 bss-1]$ cat x.c
char *heap_start;
extern char *__bss_start;

void my_init_stacktrace()
{
  heap_start = (char*) &__bss_start;
}

int
main ()
{
  my_init_stacktrace ();
  return 0;
}
[hjl@gnu-skx-1 bss-1]$ cat foo.c
void
foo (void)
{
}
[hjl@gnu-skx-1 bss-1]$ cat libfoo.map 
FOO {
  global:
    *;
};
[hjl@gnu-skx-1 bss-1]$ make
gcc -m32 -fpie -O2    -c -o x.o x.c
gcc -m32 -fpie -O2  -fpic   -c -o foo.o foo.c
gcc -m32 -shared -o libfoo.so foo.o -Wl,--version-script,libfoo.map
gcc -m32 -pie -o x x.o libfoo.so -Wl,-R.
/usr/local/bin/ld: BFD (Linux/GNU Binutils) 2.30.51.0.1.20180507 assertion fail /net/gnu-4/export/linux/src/binutils/binutils/bfd/elf32-i386.c:3953
collect2: error: ld returned 1 exit status
make: *** [Makefile:15: x] Error 1
[hjl@gnu-skx-1 bss-1]$
Comment 1 H.J. Lu 2018-05-10 20:43:39 UTC
Created attachment 11002 [details]
A patch

I am testing this.
Comment 2 H.J. Lu 2018-05-11 02:39:09 UTC
Comment on attachment 11002 [details]
A patch

The patch is posted at

https://sourceware.org/ml/binutils/2018-05/msg00127.html
Comment 3 Sourceware Commits 2018-05-14 10:49:11 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=9bc935ef3380a2d471b9447e2bf8e61297654e2f

commit 9bc935ef3380a2d471b9447e2bf8e61297654e2f
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon May 14 03:47:47 2018 -0700

    x86: Mark __bss_start, _end and _edata locally defined
    
    __bss_start, _end and _edata are defined by linker to mark regions
    within executables and shared libraries.  All references within
    executables should be locally resolved.
    
    This patch doesn't change how their references within shared libraries
    are resolved.
    
    bfd/
    
    	PR ld/23162
    	* elfxx-x86.c (elf_x86_linker_defined): New function.
    	(_bfd_x86_elf_link_check_relocs): Use it to mark __bss_start,
    	_end and _edata locally defined within executables.
    
    ld/
    
    	PR ld/23162
    	* testsuite/ld-elf/pr23162.map: New file.
    	* testsuite/ld-elf/pr23162.rd: Likewise.
    	* testsuite/ld-elf/pr23162a.c: Likewise.
    	* testsuite/ld-elf/pr23162b.c: Likewise.
    	* testsuite/ld-elf/shared.exp: Run PR ld/23162 tests.
Comment 4 H.J. Lu 2018-05-14 10:49:44 UTC
Fixed for 2.31.