Don't generate empty reloc sections

binutils/

	PR binutils/13947
	* objcopy.c (copy_object): Call copy_relocations_in_section
	before copy_section.
	(skip_section): New.
	(copy_relocations_in_section): Likewise.
	(copy_section): Use skip_section.  Don't copy relocations here.

binutils/testsuite/

	PR binutils/13947
	* binutils-all/i386/compressed-1b.d: Remove empty REL section.
	* binutils-all/i386/compressed-1c.d: Likewise.

	* binutils-all/x86-64/compressed-1b.d: Remove empty RELA
	section.
	* binutils-all/x86-64/compressed-1c.d: Likewise.
This commit is contained in:
H.J. Lu 2012-04-13 02:52:34 +00:00
parent e319fa28f9
commit c398915025
7 changed files with 92 additions and 38 deletions

View file

@ -5,15 +5,14 @@
#readelf: -S --wide
#name: strip on uncompressed debug sections
There are 6 section headers, starting at offset 0x7c:
There are 5 section headers, starting at offset 0x78:
Section Headers:
\[Nr\] Name Type Addr Off Size ES Flg Lk Inf Al
\[ 0\] NULL 00000000 000000 000000 00 0 0 0
\[ 1\] .text PROGBITS 00000000 000040 00001b 00 AX 0 0 16
\[ 2\] .rel.text REL 00000000 00016c 000000 08 0 1 4
\[ 3\] .data PROGBITS 00000000 00005c 000000 00 WA 0 0 4
\[ 4\] .bss NOBITS 00000000 00005c 000000 00 WA 0 0 4
\[ 5\] .shstrtab STRTAB 00000000 00005c 000020 00 0 0 1
\[ 2\] .data PROGBITS 00000000 00005c 000000 00 WA 0 0 4
\[ 3\] .bss NOBITS 00000000 00005c 000000 00 WA 0 0 4
\[ 4\] .shstrtab STRTAB 00000000 00005c 00001c 00 0 0 1
Key to Flags:
#...

View file

@ -5,15 +5,14 @@
#readelf: -S --wide
#name: strip on compressed debug sections
There are 6 section headers, starting at offset 0x7c:
There are 5 section headers, starting at offset 0x78:
Section Headers:
\[Nr\] Name Type Addr Off Size ES Flg Lk Inf Al
\[ 0\] NULL 00000000 000000 000000 00 0 0 0
\[ 1\] .text PROGBITS 00000000 000040 00001b 00 AX 0 0 16
\[ 2\] .rel.text REL 00000000 00016c 000000 08 0 1 4
\[ 3\] .data PROGBITS 00000000 00005c 000000 00 WA 0 0 4
\[ 4\] .bss NOBITS 00000000 00005c 000000 00 WA 0 0 4
\[ 5\] .shstrtab STRTAB 00000000 00005c 000020 00 0 0 1
\[ 2\] .data PROGBITS 00000000 00005c 000000 00 WA 0 0 4
\[ 3\] .bss NOBITS 00000000 00005c 000000 00 WA 0 0 4
\[ 4\] .shstrtab STRTAB 00000000 00005c 00001c 00 0 0 1
Key to Flags:
#...