How to limit the size of the gap between sections using objcopy?

Nick Clifton nickc@redhat.com
Wed Nov 26 10:37:00 GMT 2008


Hi Pan,

> I need to create raw binary files from ELFs in my project. If the
> linker script of some ELF is like
> 
> SECTIONS {
>   .syslibc 0x80001000: { ... }
>   .text 0xa0004000: { ... }
> }
> 
> There will be a big gap between the section .syslibc and .text. And I
> run objcopy, objcopy will try to fill the gap, which is not really
> what I want. I want in the case objcopy will stop and report an error
> so that I can check and fix the linker scripts.

Ok, I understand now.  Unfortunately the answer is "no".  Objcopy does 
not have any facilities to abort its operation if the output file is 
going to be too big, or to have to huge gaps inside it.

You can either modify objcopy to add this functionality, or else you 
could write a shell script which runs objdump or readelf, extracts the 
section start addresses and sizes and then computes whether the 
resulting converted binary will be too big.

Cheers
   Nick




More information about the Binutils mailing list