This two commands run on s390x build of Fedora 9 gcc -O2 -o fba0.exec -nostdlib -Wl,-Ttext,0 fba0.o objcopy -O binary fba0.exec fba0.bin will produce a 2 GB large file from fba0.o file. Version-Release number of selected component (if applicable): gcc (GCC) 4.3.0 20080428 (Red Hat 4.3.0-8) package binutils-2.18.50.0.6-2.s390x GNU ld version 2.18.50.0.6-2 20080403 GNU objcopy version 2.18.50.0.6-2 20080403 current upstream GNU ld (Linux/GNU Binutils) 2.19.50.0.1.20081007 GNU objcopy (Linux/GNU Binutils) 2.19.50.0.1.20081007 using gcc/ld/objcopy from RHEL5 gives correct output gcc (GCC) 4.1.2 20070626 (Red Hat 4.1.2-14) GNU ld version 2.17.50.0.6-5.el5 20061020 GNU objcopy 2.17.50.0.6-5.el5 20061020 It looks to me that something is wrong with the fba0.exec file produced on Fedora, because when I take objcopy from RHEL5, it creates the same 2 GB large file. Steps to Reproduce: 0. gcc -Wall -O3 -DS390_TOOLS_RELEASE=1.7.0 -I../include -D__ASSEMBLY__ -DVERSION=1 -DRELEASE=7 -DPATCHLEVEL=0 -c -o fba0.o fba0.S 1. gcc -O2 -o fba0.exec -nostdlib -Wl,-Ttext,0 fba0.o 2. objcopy -O binary fba0.exec fba0.bin Fedora for s390x lives at https://s390.koji.fedoraproject.org/koji/index
Created attachment 321142 [details] using RHEL5 gcc + binutils
Created attachment 321143 [details] using Fedora 9 gcc + binutils
Created attachment 321144 [details] using Fedora 9 gcc + recent binutils built from upstream sources
Hi Dan, This is happening because of a "feature" in the linker. An extra section is being added to the executable file, and the presence of this section (starting at address 0x800000e8) is causing the conversion to the binary format to grow to the 2Gb size you noted. Run "objdump -h fba0.exec" to see this section: fba0.exec: file format elf64-s390 Sections: Idx Name Size VMA LMA File off Algn 0 .text 000000e8 0000000000000000 0000000000000000 00001000 2**2 CONTENTS, ALLOC, LOAD, READONLY, CODE 1 .note.gnu.build-id 00000024 00000000800000e8 00000000800000e8 000010e8 2**2 CONTENTS, ALLOC, LOAD, READONLY, DATA The presence of this section is not the linker's fault though. It is being requested by gcc. If you add the "-v" option to the command line in step 1 of your "Steps to Reproduce" you will see lots of output including an invocation of the collect2 program (a wrapper around the linker) in which the "--build-id" option is present. It is this option which is responsible for the creation of the .note.gnu.build-id section. To prevent this section from being created, and so restore normal sized binaries, add --build-id=none to the linker command line. Ie step 1 should read: 1. gcc -O2 -o fba0.exec -nostdlib -Wl,-Ttext,0 fba0.o -Wl,--build-id=none I hope that this helps. Cheers Nick Clifton
Thanks for the explanation, Nick. I have just found another method - process only the .text section with objcopy objcopy -O binary -j .text fba0.exec fba0.bin