objcopy, --change-section-lma ?

Nick Clifton nickc@redhat.com
Mon Jun 12 12:57:00 GMT 2006


Hi Torsten,

   When dealing with this sort of question it is important to be 
specific about what is being discussed, so let me point out a few minor 
assumptions first:

> to my understanding in a section header entry there are 10 values
> of 32 bit each.

For 32 bit files.  For 64 bit files the values are 64 bit.

> One reflects the VMA (SH_ADDR), but none reflectsthe LMA.

In the ELF file format.  Other file formats can be supported by objcopy 
and they may or may not have such a field.

> I wondered how objcopy can change a sections LMA then and found out that
> it changes one of the program headers.

> I now wonder how it is ensured that this does not contradict to the
> LMA of other sections?

When processing the modified executable prior to writing it out objcopy 
(via the BFD library) should check for conflicting LMAs and report any 
problems.

> Are other sections affected implicitly?

No, only the section(s) specified on the objcopy command line should be 
adjusted.

> Or does objcopy add another program header if necessary?

Yes.

> If it does that, how is a section linked to a program header?

They are not.  An ELF file can have either program headers or section 
headers or both.  If it has both then there is an assumed mapping 
between the sh_addr fields of the section headers and the (p_vaddr + 
p_memsz) address range of the program headers.  Corrupt ELF files may 
not conform to this assumption.  It is intended that a program loader 
can ignore any section headers in an ELF file entirely and instead just 
use the program headers.

Cheers
   Nick



More information about the Binutils mailing list