This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Symbol values in memory word units


Oleg Volf <ykvolf@yahoo.com> writes:

>> >> linker expects section's vma and lma in byte units
>> >
>> > See bfd_arch_mach_octets_per_byte and OCTETS_PER_BYTE.
>> 
>> But in practice these are poorly defined and it is really hard to use
>> these successfully.  What I've done in the past is keep symbol values
>> and relocation addresses in bytes, and adjust in the relocation
>> routines.  This means that nm, objdump, readelf print the wrong
>> values, but it's not a difficult mental adjustment.
>
> The problem, actually, is more complicated. Our architecture has non-unified memory.  Different  memories have different memory word sizes. When assembler sees instruction like this:
> ld $r1, label + 5
> it does not know in which section symbol is defined (section
> corresponds to memory type) and creates "generic" data relocation.

The way I've handled that in the past is by using the linker script to
segregate different memory areas by setting high bits in the address
space.  The high bits were outside the range of valid addresses.
Those bits were then attached to symbols based on the section in which
they were defined.  The relocation routines could then see from the
symbol address and the relocation address the right sort of
computation to make.  The high bits were masked out when computing the
values to store into the final executable.


> In this  implementation  I suppose  that both addend  and  relocation address are  in  words.
> I, probably, can implement this approach with with modified bfd_arch_mach_octets_per_byte() if "current" section is available. Does linker have interface to access "current" section?

The notion of the current section is not well-defined during the
link.  Assuming you ask asking about the relocation computations,
then, yes, the linker knows the section which contains the data which
is being relocated.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]