Timothy Truckle
Timothy Truckle

Reputation: 15622

how to avoid objcopy blowing up the file?

I use objcopy to extract/replace some section is an ELF file on a windows system.

>objcopy.exe -V
GNU objcopy 2.17.50 20060824
Copyright 2005 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License.  This program has absolutely no warranty.

This works in general.

But my elf file contains debug information which I need to remove before delivery to decrese the filesize.

I found tht option -g or --strip-debug should do what I want:

>"objcopy.exe" --strip-debug -I elf32-big -O elf32-big with-debug.elf without-debug.elf

But it fails miserably. instead of making the file smaller it blows up the file size from ~20MB to 3GB before failing with:

objcopy.exe: without-debug.elf: File truncated
objcopy.exe: without-debug.elf: No space left on device

how do I corectly remove debug information from ELF using objcopy?


Don't know if this is important but objcopy issues some warnings for most ot the sections in the ELF like this:

BFD: without-debug.elf: warning: allocated section `.sdata' not in segment

Upvotes: 1

Views: 679

Answers (1)

Employed Russian
Employed Russian

Reputation: 213626

Sounds like a bug in binutils.

You are using 10 year old version, and not an official release but a snapshot taken at random time.

I would try current release of binutils (version 2.28) first -- there is a chance whatever bug you are hitting has already been fixed. And if it hasn't, you can report it in binutils bugzilla.

Upvotes: 1

Related Questions