This is the mail archive of the binutils@sources.redhat.com 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]

Re: Linking images at one address, but loading them at another.


Hi Richard,

> However, this image contains symbols, if I try to strip the image
> (eg to  remove debug data):
> 
> arm-elf-strip -g -o os os.gdb 
> BFD: netbsd: warning: allocated section `.text' not in segment

Not sure about this one.  It sounds like a bug in strip.  Can you
create a small example for us to test ?

> Is there some other way of setting the load address of a segment 
> symbolically?

This sounds like a job for memory regions.  For example this script:

  ENTRY(os_start)
  MEMORY
  {
    low     : ORIGIN = 0x00010000, LENGTH = 0x1000
    normal  : ORIGIN = 0xa0110000, LENGTH = 0x100000
  }
  SECTIONS
  {
    .lotex  : { os_start.o(.text)  } >low    
    .text   : { *(.text) *(.glue*) } >normal AT>low =0
    .data   : { *(.data) *(.bss)   } >normal AT>low 
  }

Produced an executable that looked like this:

  Sections:
  Idx Name          Size      VMA       LMA       File off  Algn
    0 .lotex        00000004  00010000  00010000  00008000  2**2
    1 .text         00000014  a0110000  00010004  00010000  2**2
    2 .data         00000004  a0110014  00010018  00010014  2**2
    3 .comment      00000050  00000000  00000000  00010018  2**0

However, it seems that the MEMORY and PHDRS constructs do not play
nicely together, since if you define your own PHDRS, these seem to
override the AT> memory specification.  :-(  But if you let the linker
create its own headers, things seem to work.

Cheers
        Nick


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