Reputation: 1
`Hello everyone, I'm new in that domain (linker script and memory section).
I have an array that I want to declare in a section of my address space of my processor (neorv32). I do this for various other reasons. When I try to print my table I have totally different values
In my linker script, I declared a back (rwx): ORIGIN = 0xF0000000, LENGTH = 512K
zone in the MEMORY{}
zone i checked on the neorv32 documentation and the zone is one where i can write and read data.
Then in the SECTIONS{} area I have:
.background_section: ALIGN(4)
{
__background_start = .;
KEEP(*(.background_section))
__background_end = .;
} > back
Then to initialize my table I did in a .c:
__attribute__((section(".background_section"))) uint32_t background[12] = {
0xBDEBDEBD,0xEBDEBDEB,0xDEBDEBDE,
0xBDEBDEBD,0xEBDEBDEB,0xDEBDEBDD,
0xBDEBDDBD,0xDBDDBCDA,0xCDACDACD,
0xBCDBCDBC,0xDBDDBDDB,0xDDBDDBDD};
size of 12 for the example but i got 122400 data
and when then in my main.c I want to print my values from my array I see that I have values that do not correspond to the initialized ones.
here is what I have in my .map:
.background_section
0xf0000000 0x30
0xf0000000 __background_start = .
*(.background_section)
.background_section
0xf0000000 0x30 ./main.c.o
0xf0000000 background
0xf0000030 __background_end = .
here is the section header :
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .text PROGBITS 00000000 001000 000ddc 00 AX 0 0 4
[ 2] .rodata PROGBITS 00000ddc 001ddc 000310 00 A 0 0 4
[ 3] .background_[...] PROGBITS f0000000 003000 000030 00 WA 0 0 4
[ 4] .data PROGBITS 80000000 003030 000000 00 WA 0 0 4
[ 5] .bss NOBITS 80000000 003000 000074 00 WA 0 0 4
[ 6] .heap PROGBITS 80000074 003030 000000 00 W 0 0 4
[ 7] .comment PROGBITS 00000000 003030 00000f 01 MS 0 0 1
[ 8] .riscv.attributes RISCV_ATTRIBUTE 00000000 00303f 000035 00 0 0 1
[ 9] .debug_aranges PROGBITS 00000000 003078 0001a0 00 0 0 8
[10] .debug_info PROGBITS 00000000 003218 002fe9 00 0 0 1
[11] .debug_abbrev PROGBITS 00000000 006201 00091d 00 0 0 1
[12] .debug_line PROGBITS 00000000 006b1e 002e0a 00 0 0 1
[13] .debug_frame PROGBITS 00000000 009928 0004c8 00 0 0 4
[14] .debug_str PROGBITS 00000000 009df0 002131 01 MS 0 0 1
[15] .debug_loclists PROGBITS 00000000 00bf21 000c3b 00 0 0 1
[16] .debug_rnglists PROGBITS 00000000 00cb5c 0001aa 00 0 0 1
[17] .debug_line_str PROGBITS 00000000 00cd06 0002b1 01 MS 0 0 1
[18] .symtab SYMTAB 00000000 00cfb8 0013f0 10 19 274 4
[19] .strtab STRTAB 00000000 00e3a8 00088e 00 0 0 1
[20] .shstrtab STRTAB 00000000 00ec36 0000e6 00 0 0 1
and here is what I have with the command objdump -s -j .background_section
:
f0000010 ebbddeeb ddebbdde bdddebbd dabcdddb ................
f0000020 cddaaccd bccddbbc dbbddddb dddbbddd ................```
Thank you for your feedback
Upvotes: 0
Views: 104