[LLVMdev] ELF section load address

Colin LeMahieu colinl at codeaurora.org
Thu Oct 30 08:41:02 PDT 2014


We had a need for calculating an ELF section load address, essentially the
LMA address printed out from GNU objdump with the –h option:

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .start        00003dc0  00000000  00000000  00001000  2**6

It looks like GNU binutils calculates this by applying the delta between the
vaddr and paddr of the section's enclosing segment.

I implemented this inside llvm-readobj:

  Section {
    Index: 30
    Name: .strtab (9)
    Type: SHT_STRTAB (0x3)
    Flags [ (0x0)
    ]
    Address: 0x0
    Load Address: 0x0
    Offset: 0x64FF88
    Size: 2689979
    Link: 0
    Info: 0
    AddressAlignment: 1
    EntrySize: 0
  }

Is there interest in this being upstreamed?  It's a small patch.

Is this the best place to put this information inside of llvm-readobj and
underneath the 'Address:' line.  If there's a better place let me know.

Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, 
a Linux Foundation Collaborative Project






More information about the llvm-dev mailing list