/tmp/ecp.* created during kernel build?
Ed Maste
emaste at freebsd.org
Thu Mar 30 19:29:47 UTC 2017
[redirected to freebsd-toolchain]
On 24 March 2017 at 08:21, Andre Albsmeier <Andre.Albsmeier at siemens.com> wrote:
>
> Interesting is also that libc.a grows(!):
>
> Before the strip:
> -r--r----- 1 andre wheel 2622684 24 Mar 13:18 libc.a
>
> After:
> -r--r----- 1 andre wheel 2713792 24 Mar 13:19 libc.a
It seems this is a side effect of the way elfcopy writes the new
archive and objects.
Using diffoscope to compare libc.a and a stripped libc.a we see a few
interesting things:
% objcopy --strip-debug /usr/lib/libc.a libc.strip1.a
% diffoscope /usr/lib/libc.a libc.strip1.a
--- /usr/lib/libc.a
+++ libc.strip1.a
├── file list
│ @@ -1,1258 +1,1258 @@
│ ----------- 0 0 0 83210 1970-01-01 00:00:00.000000 /
│ +---------- 0 0 0 83210 2017-03-30 19:01:14.000000 /
* Elfcopy is updating the timestamp on the "/" entry, despite leaving
all other archive metadata alone.
│ --rw-r--r-- 0 0 0 1104 1970-01-01
00:00:00.000000 iconvlist.o
│ +-rw-r--r-- 0 0 0 1184 1970-01-01
00:00:00.000000 iconvlist.o
* As you discovered output is larger, and this is true for the
individual .o files in the .a archive.
│ File: lib.a(iconvctl.o)
│ ELF Header:
│ Magic: 7f 45 4c 46 02 01 01 09 00 00 00 00 00 00 00 00
│ Class: ELF64
│ Data: 2's complement, little endian
│ Version: 1 (current)
│ OS/ABI: FreeBSD
│ ABI Version: 0
│ Type: REL (Relocatable file)
│ Machine: Advanced Micro Devices x86-64
│ Version: 0x1
│ Entry point address: 0
│ Start of program headers: 0 (bytes into file)
│ - Start of section headers: 528 (bytes into file)
│ + Start of section headers: 536 (bytes into file)
│ Flags: 0
│ Size of this header: 64 (bytes)
│ Size of program headers: 0 (bytes)
│ Number of program headers: 0
│ Size of section headers: 64 (bytes)
│ - Number of section headers: 9
│ - Section header string table index: 1
│ + Number of section headers: 10
│ + Section header string table index: 9
Section headers are at a different offset, elfcopy/strip output has an
extra section.
├── readelf --wide --sections {}
│ @@ -1,23384 +1,24634 @@
│
│ File: lib.a(iconvlist.o)
│ -There are 9 section headers, starting at offset 0x210:
│ +There are 10 section headers, starting at offset 0x220:
│
│ Section Headers:
│ [Nr] Name Type Addr Off
Size ES Flg Lk Inf Al
│ [ 0] NULL 0000000000000000 000000
000000 00 0 0 0
│ - [ 1] .strtab STRTAB 0000000000000000 000180
00008c 00 0 0 1
│ - [ 2] .text PROGBITS 0000000000000000 000040
00000a 00 AX 0 0 16
│ - [ 3] .rela.text RELA 0000000000000000 000150
000018 18 8 2 8
│ - [ 4] .comment PROGBITS 0000000000000000 00004a
000053 01 MS 0 0 1
│ - [ 5] .note.GNU-stack PROGBITS 0000000000000000 00009d
000000 00 0 0 1
│ - [ 6] .eh_frame X86_64_UNWIND 0000000000000000 0000a0
000038 00 A 0 0 8
│ - [ 7] .rela.eh_frame RELA 0000000000000000 000168
000018 18 8 6 8
│ - [ 8] .symtab SYMTAB 0000000000000000 0000d8
000078 18 1 3 8
│ + [ 1] .text PROGBITS 0000000000000000 000040
00000a 00 AX 0 0 16
│ + [ 2] .rela.text RELA 0000000000000000 000180
000018 18 I 7 1 8
│ + [ 3] .comment PROGBITS 0000000000000000 00004a
000053 01 MS 0 0 1
│ + [ 4] .note.GNU-stack PROGBITS 0000000000000000 00009d
000000 00 0 0 1
│ + [ 5] .eh_frame X86_64_UNWIND 0000000000000000 0000a0
000038 00 A 0 0 8
│ + [ 6] .rela.eh_frame RELA 0000000000000000 000198
000018 18 I 7 5 8
│ + [ 7] .symtab SYMTAB 0000000000000000 0000d8
0000a8 18 8 5 8
│ + [ 8] .strtab STRTAB 0000000000000000 0001b0
00001b 00 0 0 1
│ + [ 9] .shstrtab STRTAB 0000000000000000 0001cb
00004e 00 0 0 1
│ Key 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)
Sections are in a different order, and elfcopy/strip includes a
separate section header string table, while Clang's output stores both
symbol names and names used in the section header in .strtab. The
increased size is interesting and somewhat unfortunate, but not
necessarily a bug.
> strip (objcopy) does more curious things:
>
> $ cd /tmp
> $ cp /usr/lib/libc.a .
> $ strip --strip-debug libc.a
> $ strip --strip-debug libc.a
>
> [1] 960 segmentation fault strip --strip-debug libc.a
This is also reproducible as:
% objcopy --strip-debug /usr/lib/libc.a libc.1.a
% objcopy --strip-debug libc.1.a libc.2.a
zsh: bus error (core dumped) objcopy --strip-debug libc.1.a libc.2.a
It wasn't reproducible in some trivial cases I tried though (e.g. .a
archive with two trivial .o objects), or with some other .a archives:
% objcopy --strip-debug /usr/lib/libm.a libm.1.a
% objcopy --strip-debug libm.1.a libm.2.a
%
I've submitted ELF Tool Chain ticket #548 for this issue
https://sourceforge.net/p/elftoolchain/tickets/548/
More information about the freebsd-toolchain
mailing list