Bug 468017 - output from objcopy is too large (2 GB)
output from objcopy is too large (2 GB)
Product: Fedora
Classification: Fedora
Component: binutils (Show other bugs)
s390x Linux
medium Severity medium
: ---
: ---
Assigned To: Nick Clifton
Fedora Extras Quality Assurance
Depends On:
Blocks: ZedoraTracker
  Show dependency treegraph
Reported: 2008-10-22 08:58 EDT by Dan Horák
Modified: 2008-10-29 08:02 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2008-10-29 08:02:58 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
using RHEL5 gcc + binutils (1.49 KB, application/x-gzip)
2008-10-22 09:00 EDT, Dan Horák
no flags Details
using Fedora 9 gcc + binutils (3.08 KB, application/x-bzip)
2008-10-22 09:01 EDT, Dan Horák
no flags Details
using Fedora 9 gcc + recent binutils built from upstream sources (3.09 KB, application/x-bzip)
2008-10-22 09:02 EDT, Dan Horák
no flags Details

  None (edit)
Description Dan Horák 2008-10-22 08:58:57 EDT
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-
  GNU ld version 20080403
  GNU objcopy version 20080403

current upstream
  GNU ld (Linux/GNU Binutils)
  GNU objcopy (Linux/GNU Binutils)

using gcc/ld/objcopy from RHEL5 gives correct output
gcc (GCC) 4.1.2 20070626 (Red Hat 4.1.2-14)
GNU ld version 20061020
GNU objcopy 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
Comment 1 Dan Horák 2008-10-22 09:00:23 EDT
Created attachment 321142 [details]
using RHEL5 gcc + binutils
Comment 2 Dan Horák 2008-10-22 09:01:16 EDT
Created attachment 321143 [details]
using Fedora 9 gcc + binutils
Comment 3 Dan Horák 2008-10-22 09:02:18 EDT
Created attachment 321144 [details]
using Fedora 9 gcc + recent binutils built from upstream sources
Comment 4 Nick Clifton 2008-10-28 07:56:28 EDT
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

  Idx Name          Size      VMA               LMA               File off  Algn
    0 .text         000000e8  0000000000000000  0000000000000000  00001000  2**2
    1 .note.gnu.build-id 00000024  00000000800000e8  00000000800000e8  000010e8  2**2

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.

  Nick Clifton
Comment 5 Dan Horák 2008-10-29 03:12:11 EDT
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

Note You need to log in before you can comment on or make changes to this bug.