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]
Other format: [Raw text]

Re: different load and execution address ...


Hi Lars,

> I know exactly what address range in sram I will use, in this case
> 0x20000000 and forward.
>
> I have tried to do what you suggest, but I haven't been able to make
> it work.
>
> When you say 'Just statically link the binary using a
>   linker script with an explicit MEMORY region set up to contain all of
>   the code/data.' do you mean something like:
>
>           __isram_src = (ADDR(.text) + SIZEOF(.text));
>
>          .isram 0x20000000 : AT (ADDR(.text) + SIZEOF(.text))
>          {
>                  __isram_begin = ABSOLUTE(.);
>                  *(.isram)
>                  __isram_end = ABSOLUTE(.);
>          }
>          __isram_image = ADDR(.isram);
>          . = LOADADDR(.isram) + SIZEOF(.isram);
>
>          __isram_src_end = ADDR(.text) + SIZEOF(.text) + SIZEOF(.isram);

Well I was thinking of using a memory region, but I think that your
method should work as well.  Here is what I had in mind, selecting the
object files to go into the region by their directory name rather than
an attribute in the code:

  MEMORY { sram (rwxa) : origin = 0x2000000, length = 2M }
  SECTIONS {  
    .text : { __isram_start = .;
              isram/*.o(.text); } > sram
    .data : { isram/*.o(.data);
              __isram_end = .; } > sram
  }
  
> So if you have any hint about how to produce a binary file from this
> and somehow extract the addresses of the functions in this binary it
> would be most appreciated.

You should be able to then create the binary with a command line like:

  ld -o binary-image -T binary-linker-script isram/*.o

To get the addresses of the functions in the binary image should be
relatively easy, assuming that the file format you are using allows
the symbol table to be stored in an executable.  (ie if you are using
ELF you are OK.  If you are using ihex or srec or something like that
then you are in trouble).

You could just run 'nm' over the binary image and grep for the
particular functions that you are interested in.  If you need to do
this programatically, then you can use the functions provided by the
bfd library (or libelf if you prefer) to load the binary-image and
read its symbol table.  (Have a look at the source for objcopy for an
example of using the bfd library to read binary files).

Cheers
        Nick


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