This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: A question about setting location counter to a new value in output section
- From: Alan Modra <amodra at gmail dot com>
- To: Hao Lee <haolee dot swjtu at gmail dot com>
- Cc: binutils at sourceware dot org
- Date: Wed, 4 Apr 2018 22:26:52 +0930
- Subject: Re: A question about setting location counter to a new value in output section
- References: <CA+PpKPkk_uyMAynks082jmxMyGHSt0nBVR+ucMNgR6K8mzyxfQ@mail.gmail.com>
On Wed, Apr 04, 2018 at 08:05:54PM +0800, Hao Lee wrote:
> I can't understand why lable_2 is 0x30. As the LD documentation
> says[0], if '.' is used inside a section description, it refers to the
> byte offset from the start of that section, not an absolute address.
> In the custom_section, '.' is set to 0x20 which is a relative offset,
> so I think label_2 should also be 0x20. The value of label_3 is
> reasonable because it's an absolute address.
Symbol values in an ELF executable or shared object are virtual
addresses, not section offsets.
http://www.sco.com/developers/gabi/latest/ch4.symtab.html#symbol_value
--
Alan Modra
Australia Development Lab, IBM