[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Simulavr-devel] Discussion: siminfo feature as proposed by Markus H
From: |
Klaus Rudolph |
Subject: |
Re: [Simulavr-devel] Discussion: siminfo feature as proposed by Markus Hitter |
Date: |
Sun, 02 Mar 2014 10:44:06 +0100 |
User-agent: |
Thunderbird 2.0.0.23 (X11/20090817) |
Was the idea to simplify the usage of all the tools?
It is easier to give:
avr-gcc -g -O2 -mmcu=atmega16 -o fred.elf
-Wl,--section-start=.siminfo=0x900000 fred.c
instead of including only a header file?
The given command line looks much more complicated than the command line
for simulavr itself with needed info parms.
I dislike this solution! Manually adding linker infos on the command
line is never an option for me. Introducing such very secial solutions
to "simplify" the usage of simulavr looks not the perfect way :-) So
please do not introduce this feature in that way. It is terrible!
Regards
Klaus
ThomasK schrieb:
> 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.
>
> _______________________________________________
> Simulavr-devel mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/simulavr-devel
>