Menu

#518 elfcopy reorders file contents (sections) on simple copy

RELEASE_1_0
new
nobody
None
2016-02-16
2016-02-16
Ed Maste
No

Found by running the GNU binutils objcopy test suite (ticket #496) - see readelf differences reported below. This is not a functional problem, although it may be preferable to leave the section ordering unchanged.

% diffoscope bintest.o bintest.o.elfcopy-output
--- bintest.o
+++ bintest.o.elfcopy-output
├── readelf --wide --file-header {}@@ -6,15 +6,15 @@OS/ABI:                            UNIX - FreeBSDABI Version:                       0Type:                              REL (Relocatable file)Machine:                           Advanced Micro Devices X86-64Version:                           0x1Entry point address:               0x0Start of program headers:          0 (bytes into file)-  Start of section headers:          128 (bytes into file)+  Start of section headers:          488 (bytes into file)Flags:                             0x0Size of this header:               64 (bytes)Size of program headers:           0 (bytes)Number of program headers:         0Size of section headers:           64 (bytes)Number of section headers:         8Section header string table index: 5
├── readelf --wide --sections {}@@ -1,16 +1,16 @@-There are 8 section headers, starting at offset 0x80:+There are 8 section headers, starting at offset 0x1e8:
│
│  Section Headers:[Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al[ 0]                   NULL            0000000000000000 000000 000000 00      0   0  0[ 1] .text             PROGBITS        0000000000000000 000040 000008 00  AX  0   0  4-  [ 2] .rela.text        RELA            0000000000000000 0003d0 000018 18      6   1  8+  [ 2] .rela.text        RELA            0000000000000000 0001d0 000018 18   I  6   1  8[ 3] .data             PROGBITS        0000000000000000 000048 000004 00  WA  0   0  4[ 4] .bss              NOBITS          0000000000000000 00004c 000000 00  WA  0   0  4[ 5] .shstrtab         STRTAB          0000000000000000 00004c 000031 00      0   0  1-  [ 6] .symtab           SYMTAB          0000000000000000 000280 0000f0 18      7   6  8-  [ 7] .strtab           STRTAB          0000000000000000 000370 00005d 00      0   0  1+  [ 6] .symtab           SYMTAB          0000000000000000 000080 0000f0 18      7   6  8+  [ 7] .strtab           STRTAB          0000000000000000 000170 00005d 00      0   0  1Key to Flags:W (write), A (alloc), X (execute), M (merge), S (strings)I (info), L (link order), G (group), x (unknown)O (extra OS processing required) o (OS specific), p (processor specific)
├── readelf --wide --relocs {}@@ -1,4 +1,4 @@
│
│ -Relocation section '.rela.text' at offset 0x3d0 contains 1 entries:+Relocation section '.rela.text' at offset 0x1d0 contains 1 entries:Offset             Info             Type               Symbol's Value  Symbol's Name + Addend0000000000000004  000000070000000a R_X86_64_32            0000000000000000 external_symbol + 0

Discussion


Log in to post a comment.