]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gas: Fix internal error in S_SET_SEGMENT
authorAlex Coplan <alex.coplan@arm.com>
Mon, 17 Aug 2020 13:23:14 +0000 (14:23 +0100)
committerAlex Coplan <alex.coplan@arm.com>
Mon, 17 Aug 2020 13:23:14 +0000 (14:23 +0100)
commitd4d05d13eba6e0ed01767999fc87e75599ddd86e
treef6334266eeab55c24929d359d6a38db7d936ef3d
parent53d5a2a5c146f98dd525eda2f33d7781666463bf
gas: Fix internal error in S_SET_SEGMENT

This patch fixes an internal error in GAS when defining a section using
a symbol that has already been named but not defined. For a minimal
reproducer, try the following input:

a=b
.sect a

The problem is that obj_elf_change_section() happily reuses the symbol
"a" created by equals() without clearing the sy_value field: prior to
this patch, it just set bsym. This caused a problem when attempting to
resolve the section symbol, since resolve_symbol_value() ended up
resolving the symbol as if it were the original symbol created by
equals(), which ends up leaving the section symbol in the undefined
section instead of in section a, hence the call to abort() in
S_SET_SEGMENT().

gas/ChangeLog:

* config/obj-elf.c (obj_elf_change_section): When repurposing an
existing symbol, ensure that we set sy_value as per other (fresh)
section symbols.
* testsuite/gas/elf/elf.exp: Add new test.
* testsuite/gas/elf/section-symbol-redef.d: New test.
* testsuite/gas/elf/section-symbol-redef.s: Input for test.
gas/ChangeLog
gas/config/obj-elf.c
gas/testsuite/gas/elf/elf.exp
gas/testsuite/gas/elf/section-symbol-redef.d [new file with mode: 0644]
gas/testsuite/gas/elf/section-symbol-redef.s [new file with mode: 0644]