simulavr-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Simulavr-devel] Discussion: siminfo feature as proposed by Markus H


From: ThomasK
Subject: Re: [Simulavr-devel] Discussion: siminfo feature as proposed by Markus Hitter
Date: Sun, 02 Mar 2014 09:36:40 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130330 Thunderbird/17.0.5

Hi,

to clarify one part of the discussion about siminfo: with the information from Markus I have made some tests about .signature and .siminfo section in elf file. Result: get .siminfo section into elf file is easy, just a command line option on compile/link. Markus has found out this and he has also created an example in his patches, where you can see this. (see below for the results)

Other tools might not use __signature .
Anyone know for sure?
They might just use the first 1, 2 or 3 bytes of .signature .
Those might be siminfo bytes instead of signature bytes.
For that matter, if .signature has no signature data, but it has siminfo
data,
said data would likely be mistaken for signature data.

That's the point in my opinion not to use signature section. And as you can see below, it's not necessary.

cu, Thomas

-----------------------------------------

I use the examples/simple_ex1/fred.c as source. Compile and link:

> avr-gcc -g -O2 -mmcu=atmega16 -o fred.elf fred.c

will give the following:

> readelf -S fred.elf

Section Headers:
  [Nr] Name         Type         Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]              NULL         00000000 000000 000000 00      0   0  0
  [ 1] .text        PROGBITS     00000000 000074 0000f6 00  AX  0   0  2
  [ 2] .data        PROGBITS     00800060 00016a 000058 00  WA  0   0  1
  [ 3] .stab        PROGBITS     00000000 0001c4 000954 0c      4   0  4
  [ 4] .stabstr     STRTAB       00000000 000b18 000376 00      0   0  1
  [ 5] .shstrtab    STRTAB       00000000 000e8e 000036 00      0   0  1
  [ 6] .symtab      SYMTAB       00000000 001004 000410 10      7  17  4
  [ 7] .strtab      STRTAB       00000000 001414 0002d0 00      0   0  1

(result is shortend!) Now I add in fred.c on line 8 (after the heading comment):

#include <avr/signature.h>

Compile and link will show:

> readelf -S fred.elf

Section Headers:
  [Nr] Name         Type         Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]              NULL         00000000 000000 000000 00      0   0  0
  [ 1] .text        PROGBITS     00000000 000094 0000f6 00  AX  0   0  2
  [ 2] .data        PROGBITS     00800060 00018a 000058 00  WA  0   0  1
  [ 3] .signature   PROGBITS     00840000 0001e2 000003 00   A  0   0  1
  [ 4] .stab        PROGBITS     00000000 0001e8 000b64 0c      5   0  4
  [ 5] .stabstr     STRTAB       00000000 000d4c 00083b 00      0   0  1
  [ 6] .shstrtab    STRTAB       00000000 001587 000041 00      0   0  1
  [ 7] .symtab      SYMTAB       00000000 001730 000430 10      8  18  4
  [ 8] .strtab      STRTAB       00000000 001b60 0002dc 00      0   0  1

> readelf -x .signature fred.elf

Hex dump of section '.signature':
  0x00840000 03941e                              ...

Now I add BEFORE the include statement:

const unsigned long _test_ __attribute__((section (".signature"))) = 0x11223344;
#include <avr/signature.h>

This brings:

Hex dump of section '.signature':
  0x00840000 44332211 03941e                     D3"....

This shows the problem with .signature section, even with the order inside of one file or if this is spread over a few object files, which are linked later.

Markus solution is to give the linker some information, how to work with .siminfo:

Instead of the changes before I add to line 8 in fred.c:

const unsigned long _test_ __attribute__((section (".siminfo"))) = 0x11223344;

The compile-and-link command:

avr-gcc -g -O2 -mmcu=atmega16 -o fred.elf -Wl,--section-start=.siminfo=0x900000 fred.c

Readelf shows:

> readelf -S fred.elf

Section Headers:
  [Nr] Name         Type         Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]              NULL         00000000 000000 000000 00      0   0  0
  [ 1] .siminfo     PROGBITS     00900000 0001e2 000004 00   A  0   0  1
  [ 2] .text        PROGBITS     00000000 000094 0000f6 00  AX  0   0  2
  [ 3] .data        PROGBITS     00800060 00018a 000058 00  WA  0   0  1
  [ 4] .stab        PROGBITS     00000000 0001e8 000960 0c      5   0  4
  [ 5] .stabstr     STRTAB       00000000 000b48 00038c 00      0   0  1
  [ 6] .shstrtab    STRTAB       00000000 000ed4 00003f 00      0   0  1
  [ 7] .symtab      SYMTAB       00000000 00107c 000430 10      8  18  4
  [ 8] .strtab      STRTAB       00000000 0014ac 0002d7 00      0   0  1

> readelf -x .siminfo fred.elf

Hex dump of section '.siminfo':
  0x00900000 44332211                            D3".

So, it's not a problem at all to create the .siminfo section and link it together into a elf file.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]