This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
4 bytes change between two objcopy calls
- From: binutils_mlist at arcor dot de
- To: binutils at sourceware dot org
- Date: Fri, 2 Oct 2009 12:01:13 +0200 (CEST)
- Subject: 4 bytes change between two objcopy calls
Hello folks!
Right now we are working with openembedded and bitbake to create our own distribution for our systems. One
of our goals is that we can build the whole distribution on two different days with the same result. The
same result is verified by comparing the checksums of the result files.
We have already patched a bunch of tools (busybox, tinylogin, ntp, ...) which include the build date and time
during compilation. But now, there are quite a few executeables and libraries left, which differ by exaclty
4 successive bytes between builds.
I used the strace package to find out the reason for this issue. I figured out, that objcopy inserts these
bytes when called with the option --add-gnu-debuglink by the package.bbclass file from openembedded. We
currently are using binutils 2.18.
After having a look at the ltrace output when calling objcopy I see that strlen() is being called for the
string "strace", but 12 byte uninitialized memory is retrieved afterwards from the heap. After copying
"strace" into this memory, the whole 12 bytes are written to the output file. Is there a chance, that
uninitialized memory is being written to the output file?
I added the relevant output from ltrace and strace. Please notice that I have markes the 4 bytes
in the strace output.
ltrace output: (when calling objcopy)
[...]
fread(0x80ee520, 1, 8192, 0x9c72528) = 8192
fread(0x80ee520, 1, 8192, 0x9c72528) = 3689
fread(0x80ee520, 1, 8192, 0x9c72528) = 0
fclose(0x9c72528) = 0
strlen("strace") = 6
malloc(12) = 0x9c73328
strcpy(0x9c73328, "strace") = 0x9c73328
fwrite("strace", 1, 12, 0x9c72278) = 12
fwrite("", 1, 1, 0x9c72278) = 1
fwrite(".symtab", 1, 0, 0x9c72278) = 0
fwrite(".strtab", 1, 0, 0x9c72278) = 0
fwrite(".shstrtab", 1, 10, 0x9c72278) = 10
fwrite(".interp", 1, 8, 0x9c72278) = 8
[...]
strace output: (when calling objcopy)
[...]
write(4, "\0\0\0\0\0\0\0\0(\0\0\0 \0\0\0\0\0\0@\377\377\377\377\377\377\377\377@B\17\0\0"..., 445) = 445
| 00000 00 00 00 00 00 00 00 00 28 00 00 00 20 00 00 00 ........ (... ... |
| 00010 00 00 00 40 ff ff ff ff ff ff ff ff 40 42 0f 00 ...@.... ....@B.. |
| 00020 00 00 00 00 ff ff ff ff 00 00 00 00 00 00 00 00 ........ ........ |
| 00030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........ |
| 00040 01 00 00 00 f0 37 06 08 02 00 00 00 f8 37 06 08 .....7.. .....7.. |
| 00050 04 00 00 00 01 38 06 08 40 00 00 00 0a 38 06 08 .....8.. @....8.. |
| 00060 80 00 00 00 16 38 06 08 00 01 00 00 22 38 06 08 .....8.. ...."8.. |
| 00070 00 02 00 00 2e 38 06 08 00 04 00 00 3a 38 06 08 .....8.. ....:8.. |
| 00080 08 00 00 00 43 38 06 08 10 00 00 00 4c 38 06 08 ....C8.. ....L8.. |
| 00090 00 00 00 40 55 38 06 08 00 00 00 80 62 38 06 08 ...@U8.. ....b8.. |
| 000a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........ |
| 000b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........ |
| 000c0 01 00 00 00 6a 38 06 08 03 00 00 00 78 38 06 08 ....j8.. ....x8.. |
| 000d0 02 00 00 00 86 38 06 08 00 00 00 00 00 00 00 00 .....8.. ........ |
| 000e0 73 74 72 61 63 65 00 00 >e9*1d*c4*18< 00 2e 73 68 strace.. ......sh | <--- this line
| 000f0 73 74 72 74 61 62 00 2e 69 6e 74 65 72 70 00 2e strtab.. interp.. |
| 00100 6e 6f 74 65 2e 41 42 49 2d 74 61 67 00 2e 67 6e note.ABI -tag..gn |
| 00110 75 2e 68 61 73 68 00 2e 64 79 6e 73 79 6d 00 2e u.hash.. dynsym.. |
| 00120 64 79 6e 73 74 72 00 2e 67 6e 75 2e 76 65 72 73 dynstr.. gnu.vers |
| 00130 69 6f 6e 00 2e 67 6e 75 2e 76 65 72 73 69 6f 6e ion..gnu .version |
| 00140 5f 72 00 2e 72 65 6c 2e 64 79 6e 00 2e 72 65 6c _r..rel. dyn..rel |
| 00150 2e 70 6c 74 00 2e 69 6e 69 74 00 2e 74 65 78 74 .plt..in it..text |
| 00160 00 2e 66 69 6e 69 00 2e 72 6f 64 61 74 61 00 2e ..fini.. rodata.. |
| 00170 65 68 5f 66 72 61 6d 65 00 2e 63 74 6f 72 73 00 eh_frame ..ctors. |
| 00180 2e 64 74 6f 72 73 00 2e 6a 63 72 00 2e 64 79 6e .dtors.. jcr..dyn |
| 00190 61 6d 69 63 00 2e 67 6f 74 00 2e 67 6f 74 2e 70 amic..go t..got.p |
| 001a0 6c 74 00 2e 64 61 74 61 00 2e 62 73 73 00 2e 67 lt..data ..bss..g |
| 001b0 6e 75 5f 64 65 62 75 67 6c 69 6e 6b 00 nu_debug link. |
[...]
Best regards,
Daniel Kay