What is the compiler option and/or directive to change the "Addr" field of elf file?
If i use:
.bss
.data
.org 0x100000
it simply increase the "Off" and create a huge file.
The chip's ram is at 0x20000000
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 000034 0009f4 00 AX 0 0 4
[ 2] .rel.text REL 00000000 001e54 000028 08 I 19 1 4
[ 3] .data PROGBITS 00000000 000a28 000000 00 WA 0 0 1
[ 4] .bss NOBITS 00000000 000a28 000000 00 WA 0 0 1
[ 5] .rodata PROGBITS 00000000 000a28 00004c 00 A 0 0 4
user@user:~/mcu$ ls -l stm.elf
-rw-rw-r-- 1 user user 9792 May 3 07:23 stm.elf
user@user:~/mcu$ readelf -S stm.elf | head
[ 4] .bss NOBITS 00000000 100a28 000000 00 WA 0 0 1
[ 5] .rodata PROGBITS 00000000 100a28 00004c 00 A 0 0 4
user@user:~/mcu$ ls -l stm.elf
-rw-rw-r-- 1 user user 1058368 May 3 07:23 stm.elf
On 3.5.21 17.35, Ed Lee wrote:
What is the compiler option and/or directive to change the "Addr" field of elf file?
If i use:
.bss
.data
.org 0x100000
it simply increase the "Off" and create a huge file.
The chip's ram is at 0x20000000
Section Headers:The tool for it is the loader script file. Please get the GNU ld manual
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .text PROGBITS 00000000 000034 0009f4 00 AX 0 0 4
[ 2] .rel.text REL 00000000 001e54 000028 08 I 19 1 4
[ 3] .data PROGBITS 00000000 000a28 000000 00 WA 0 0 1
[ 4] .bss NOBITS 00000000 000a28 000000 00 WA 0 0 1
[ 5] .rodata PROGBITS 00000000 000a28 00004c 00 A 0 0 4
user@user:~/mcu$ ls -l stm.elf
-rw-rw-r-- 1 user user 9792 May 3 07:23 stm.elf
user@user:~/mcu$ readelf -S stm.elf | head
[ 4] .bss NOBITS 00000000 100a28 000000 00 WA 0 0 1
[ 5] .rodata PROGBITS 00000000 100a28 00004c 00 A 0 0 4
user@user:~/mcu$ ls -l stm.elf
-rw-rw-r-- 1 user user 1058368 May 3 07:23 stm.elf
from the binutils documents.
Which STM chip (and maybe demo card) are you using?
What are the memory ranges you want?
On Monday, May 3, 2021 at 11:49:42 AM UTC-7, Tauno Voipio wrote:
On 3.5.21 17.35, Ed Lee wrote:
What is the compiler option and/or directive to change the "Addr" field of elf file?
If i use:
.bss
.data
.org 0x100000
it simply increase the "Off" and create a huge file.
The chip's ram is at 0x20000000
But gcc-as does not know about the loader script, and send the global variables to the wrong place.Section Headers:The tool for it is the loader script file. Please get the GNU ld manual from the binutils documents.
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .text PROGBITS 00000000 000034 0009f4 00 AX 0 0 4
[ 2] .rel.text REL 00000000 001e54 000028 08 I 19 1 4
[ 3] .data PROGBITS 00000000 000a28 000000 00 WA 0 0 1
[ 4] .bss NOBITS 00000000 000a28 000000 00 WA 0 0 1
[ 5] .rodata PROGBITS 00000000 000a28 00004c 00 A 0 0 4
user@user:~/mcu$ ls -l stm.elf
-rw-rw-r-- 1 user user 9792 May 3 07:23 stm.elf
user@user:~/mcu$ readelf -S stm.elf | head
[ 4] .bss NOBITS 00000000 100a28 000000 00 WA 0 0 1
[ 5] .rodata PROGBITS 00000000 100a28 00004c 00 A 0 0 4
user@user:~/mcu$ ls -l stm.elf
-rw-rw-r-- 1 user user 1058368 May 3 07:23 stm.elf
Which STM chip (and maybe demo card) are you using?STM32F411: flash at 0 to 0x8000000, ram at 0x2000000 to 0x2002000.
What are the memory ranges you want?
If i use .org 0x2000000 for .data and .bss. Every ROM image is at least 33Mbytes.
I am just avoiding globals for now. But someone must have solved this problem somewhere.
On Monday, May 3, 2021 at 12:12:53 PM UTC-7, Ed Lee wrote:
On Monday, May 3, 2021 at 11:49:42 AM UTC-7, Tauno Voipio wrote:
On 3.5.21 17.35, Ed Lee wrote:But gcc-as does not know about the loader script, and send the global variables to the wrong place.
What is the compiler option and/or directive to change the "Addr" field of elf file?The tool for it is the loader script file. Please get the GNU ld manual
If i use:
.bss
.data
.org 0x100000
it simply increase the "Off" and create a huge file.
The chip's ram is at 0x20000000
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 000034 0009f4 00 AX 0 0 4
[ 2] .rel.text REL 00000000 001e54 000028 08 I 19 1 4
[ 3] .data PROGBITS 00000000 000a28 000000 00 WA 0 0 1
[ 4] .bss NOBITS 00000000 000a28 000000 00 WA 0 0 1
[ 5] .rodata PROGBITS 00000000 000a28 00004c 00 A 0 0 4
user@user:~/mcu$ ls -l stm.elf
-rw-rw-r-- 1 user user 9792 May 3 07:23 stm.elf
user@user:~/mcu$ readelf -S stm.elf | head
[ 4] .bss NOBITS 00000000 100a28 000000 00 WA 0 0 1
[ 5] .rodata PROGBITS 00000000 100a28 00004c 00 A 0 0 4
user@user:~/mcu$ ls -l stm.elf
-rw-rw-r-- 1 user user 1058368 May 3 07:23 stm.elf
from the binutils documents.
Which STM chip (and maybe demo card) are you using?STM32F411: flash at 0 to 0x8000000, ram at 0x2000000 to 0x2002000.
What are the memory ranges you want?
If i use .org 0x2000000 for .data and .bss. Every ROM image is at least 33Mbytes.
I am just avoiding globals for now. But someone must have solved this problem somewhere.
Sorry,
STM32F411: flash at 0 to 0x80000, ram at 0x20000000 to 0x20020000.
On 3.5.2021 22:14 PM, Ed Lee wrote:
On Monday, May 3, 2021 at 12:12:53 PM UTC-7, Ed Lee wrote:
On Monday, May 3, 2021 at 11:49:42 AM UTC-7, Tauno Voipio wrote:
On 3.5.21 17.35, Ed Lee wrote:But gcc-as does not know about the loader script, and send the global variables to the wrong place.
What is the compiler option and/or directive to change the "Addr" field of elf file?The tool for it is the loader script file. Please get the GNU ld manual >>> from the binutils documents.
If i use:
.bss
.data
.org 0x100000
it simply increase the "Off" and create a huge file.
The chip's ram is at 0x20000000
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 000034 0009f4 00 AX 0 0 4
[ 2] .rel.text REL 00000000 001e54 000028 08 I 19 1 4
[ 3] .data PROGBITS 00000000 000a28 000000 00 WA 0 0 1
[ 4] .bss NOBITS 00000000 000a28 000000 00 WA 0 0 1
[ 5] .rodata PROGBITS 00000000 000a28 00004c 00 A 0 0 4
user@user:~/mcu$ ls -l stm.elf
-rw-rw-r-- 1 user user 9792 May 3 07:23 stm.elf
user@user:~/mcu$ readelf -S stm.elf | head
[ 4] .bss NOBITS 00000000 100a28 000000 00 WA 0 0 1
[ 5] .rodata PROGBITS 00000000 100a28 00004c 00 A 0 0 4
user@user:~/mcu$ ls -l stm.elf
-rw-rw-r-- 1 user user 1058368 May 3 07:23 stm.elf
Which STM chip (and maybe demo card) are you using?STM32F411: flash at 0 to 0x8000000, ram at 0x2000000 to 0x2002000.
What are the memory ranges you want?
If i use .org 0x2000000 for .data and .bss. Every ROM image is at least 33Mbytes.
I am just avoiding globals for now. But someone must have solved this problem somewhere.
Sorry,
STM32F411: flash at 0 to 0x80000, ram at 0x20000000 to 0x20020000.
The way to feed the linker script is the compiler switch
-Wl,-T,myscript.ld
There is a good reason to add -Wl,-Map=myfile.map
to the compiler switches to see what the linker has done.
Please get the compiler and linker manuals and read them.
To set up the runtime system, you need a routine at the very
start to copy the initial values from the ROM to the RAM for
the .data section.
On Tuesday, May 4, 2021 at 2:38:55 AM UTC-7, Tauno Voipio wrote:
On 3.5.2021 22:14 PM, Ed Lee wrote:
On Monday, May 3, 2021 at 12:12:53 PM UTC-7, Ed Lee wrote:
On Monday, May 3, 2021 at 11:49:42 AM UTC-7, Tauno Voipio wrote:
On 3.5.21 17.35, Ed Lee wrote:But gcc-as does not know about the loader script, and send the global variables to the wrong place.
What is the compiler option and/or directive to change the "Addr" field of elf file?The tool for it is the loader script file. Please get the GNU ld manual >>>>> from the binutils documents.
If i use:
.bss
.data
.org 0x100000
it simply increase the "Off" and create a huge file.
The chip's ram is at 0x20000000
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 000034 0009f4 00 AX 0 0 4
[ 2] .rel.text REL 00000000 001e54 000028 08 I 19 1 4
[ 3] .data PROGBITS 00000000 000a28 000000 00 WA 0 0 1
[ 4] .bss NOBITS 00000000 000a28 000000 00 WA 0 0 1
[ 5] .rodata PROGBITS 00000000 000a28 00004c 00 A 0 0 4
user@user:~/mcu$ ls -l stm.elf
-rw-rw-r-- 1 user user 9792 May 3 07:23 stm.elf
user@user:~/mcu$ readelf -S stm.elf | head
[ 4] .bss NOBITS 00000000 100a28 000000 00 WA 0 0 1
[ 5] .rodata PROGBITS 00000000 100a28 00004c 00 A 0 0 4
user@user:~/mcu$ ls -l stm.elf
-rw-rw-r-- 1 user user 1058368 May 3 07:23 stm.elf
Which STM chip (and maybe demo card) are you using?STM32F411: flash at 0 to 0x8000000, ram at 0x2000000 to 0x2002000.
What are the memory ranges you want?
If i use .org 0x2000000 for .data and .bss. Every ROM image is at least 33Mbytes.
I am just avoiding globals for now. But someone must have solved this problem somewhere.
Sorry,
STM32F411: flash at 0 to 0x80000, ram at 0x20000000 to 0x20020000.
The way to feed the linker script is the compiler switch
-Wl,-T,myscript.ld
If you put this in gcc-cc command, it will pass it to gcc-ld, gcc-as will not accept this option. So, gcc-as put global variables at 0x0p and linker put them at 0x2000p (p=page of 0x0000 bytes).
There is a good reason to add -Wl,-Map=myfile.map
to the compiler switches to see what the linker has done.
Please get the compiler and linker manuals and read them.
To set up the runtime system, you need a routine at the very
start to copy the initial values from the ROM to the RAM for
the .data section.
Yes, and the assembler need to know to compile codes for address 0x2000p but put it near 0x0p. It's currently ignoring the linking instructions.
If i use ".text .org 0x100, .data .org 0x2000p and.bss .org 0x2001p", it create a 500 Mbytes file with holes (zeros). So, i need to punch it out for the rom image.
,bss is technically incorrect, because it is saying to zero out all memory between 0x0p and 0x2001p, but at least it doesn't do anything and doesn't take up any storage space.
punch stm.xlf
Section Address Offset Size
.text 00000000 00000034 00000a10 fe ff ff ea 04 b0 2d e5
.data 00000000 00000a44 20000004 78 56 34 12 fa 3f 00 20
.bss 00000000 20010a48 20010004
.rodata 00000000 20010a48 00000048 fa 3f 00 20 04 01 00 00
punch stm.elf stm.xlf
Section Address Offset Size
.text 00000100 00000034 00000910 fe ff ff ea 04 b0 2d e5
.data 20000000 e0000a44 00000004 78 56 34 12
.bss 20010000 00000a48 00000004
.rodata 00000000 00001a48 00000048 fa 3f 00 20 04 01 00 00
punch rewrite the elf sections when a third argument is provided.
On 4.5.21 16.32, Ed Lee wrote:
On Tuesday, May 4, 2021 at 2:38:55 AM UTC-7, Tauno Voipio wrote:
On 3.5.2021 22:14 PM, Ed Lee wrote:
On Monday, May 3, 2021 at 12:12:53 PM UTC-7, Ed Lee wrote:
On Monday, May 3, 2021 at 11:49:42 AM UTC-7, Tauno Voipio wrote:
On 3.5.21 17.35, Ed Lee wrote:But gcc-as does not know about the loader script, and send the global variables to the wrong place.
What is the compiler option and/or directive to change the "Addr" field of elf file?The tool for it is the loader script file. Please get the GNU ld manual
If i use:
.bss
.data
.org 0x100000
it simply increase the "Off" and create a huge file.
The chip's ram is at 0x20000000
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 000034 0009f4 00 AX 0 0 4
[ 2] .rel.text REL 00000000 001e54 000028 08 I 19 1 4
[ 3] .data PROGBITS 00000000 000a28 000000 00 WA 0 0 1
[ 4] .bss NOBITS 00000000 000a28 000000 00 WA 0 0 1
[ 5] .rodata PROGBITS 00000000 000a28 00004c 00 A 0 0 4
user@user:~/mcu$ ls -l stm.elf
-rw-rw-r-- 1 user user 9792 May 3 07:23 stm.elf
user@user:~/mcu$ readelf -S stm.elf | head
[ 4] .bss NOBITS 00000000 100a28 000000 00 WA 0 0 1
[ 5] .rodata PROGBITS 00000000 100a28 00004c 00 A 0 0 4
user@user:~/mcu$ ls -l stm.elf
-rw-rw-r-- 1 user user 1058368 May 3 07:23 stm.elf
from the binutils documents.
Which STM chip (and maybe demo card) are you using?STM32F411: flash at 0 to 0x8000000, ram at 0x2000000 to 0x2002000.
What are the memory ranges you want?
If i use .org 0x2000000 for .data and .bss. Every ROM image is at least 33Mbytes.
I am just avoiding globals for now. But someone must have solved this problem somewhere.
Sorry,
STM32F411: flash at 0 to 0x80000, ram at 0x20000000 to 0x20020000.
The way to feed the linker script is the compiler switch
-Wl,-T,myscript.ld
If you put this in gcc-cc command, it will pass it to gcc-ld, gcc-as will not accept this option. So, gcc-as put global variables at 0x0p and linker put them at 0x2000p (p=page of 0x0000 bytes).
There is a good reason to add -Wl,-Map=myfile.map
to the compiler switches to see what the linker has done.
Please get the compiler and linker manuals and read them.
To set up the runtime system, you need a routine at the very
start to copy the initial values from the ROM to the RAM for
the .data section.
Yes, and the assembler need to know to compile codes for address 0x2000p but put it near 0x0p. It's currently ignoring the linking instructions.
If i use ".text .org 0x100, .data .org 0x2000p and.bss .org 0x2001p", it create a 500 Mbytes file with holes (zeros). So, i need to punch it out for the rom image.
,bss is technically incorrect, because it is saying to zero out all memory between 0x0p and 0x2001p, but at least it doesn't do anything and doesn't take up any storage space.
punch stm.xlf
Section Address Offset Size
.text 00000000 00000034 00000a10 fe ff ff ea 04 b0 2d e5
.data 00000000 00000a44 20000004 78 56 34 12 fa 3f 00 20
.bss 00000000 20010a48 20010004
.rodata 00000000 20010a48 00000048 fa 3f 00 20 04 01 00 00
punch stm.elf stm.xlf
Section Address Offset Size
.text 00000100 00000034 00000910 fe ff ff ea 04 b0 2d e5
.data 20000000 e0000a44 00000004 78 56 34 12
.bss 20010000 00000a48 00000004
.rodata 00000000 00001a48 00000048 fa 3f 00 20 04 01 00 00
punch rewrite the elf sections when a third argument is provided.
Please show the exact command line you're using for the as, so we can correct it. If you're using GCC to assemble a .s or .S file, the
normal switches apply.
There is a good reason to use the assembler only to create the .o file
and make the linking in a separate step (using gcc again).
Please remove the .org directives from your assembler code. The linker script is the proper way to locate various program sections. If you
want to have a piece of code or data located separately, create an
own section for the blob and tell the linker where it's wanted to go.
For an example, see the section .romvec in the linker script.
What is punch? A STM weirdness?
The GNU way to look at ELF files is objdump (arm-none-elf-objdump,
maybe). objdump -h myfile.elf is the way to look in.
On Tuesday, May 4, 2021 at 7:44:05 AM UTC-7, Tauno Voipio wrote:way to do it is to patch gcc with the mmu instructions.
On 4.5.21 16.32, Ed Lee wrote:
On Tuesday, May 4, 2021 at 2:38:55 AM UTC-7, Tauno Voipio wrote:Please show the exact command line you're using for the as, so we can
On 3.5.2021 22:14 PM, Ed Lee wrote:
On Monday, May 3, 2021 at 12:12:53 PM UTC-7, Ed Lee wrote:
On Monday, May 3, 2021 at 11:49:42 AM UTC-7, Tauno Voipio wrote:
On 3.5.21 17.35, Ed Lee wrote:But gcc-as does not know about the loader script, and send the global variables to the wrong place.
What is the compiler option and/or directive to change the "Addr" field of elf file?The tool for it is the loader script file. Please get the GNU ld manual >>>>>>> from the binutils documents.
If i use:
.bss
.data
.org 0x100000
it simply increase the "Off" and create a huge file.
The chip's ram is at 0x20000000
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 000034 0009f4 00 AX 0 0 4
[ 2] .rel.text REL 00000000 001e54 000028 08 I 19 1 4
[ 3] .data PROGBITS 00000000 000a28 000000 00 WA 0 0 1
[ 4] .bss NOBITS 00000000 000a28 000000 00 WA 0 0 1
[ 5] .rodata PROGBITS 00000000 000a28 00004c 00 A 0 0 4
user@user:~/mcu$ ls -l stm.elf
-rw-rw-r-- 1 user user 9792 May 3 07:23 stm.elf
user@user:~/mcu$ readelf -S stm.elf | head
[ 4] .bss NOBITS 00000000 100a28 000000 00 WA 0 0 1
[ 5] .rodata PROGBITS 00000000 100a28 00004c 00 A 0 0 4
user@user:~/mcu$ ls -l stm.elf
-rw-rw-r-- 1 user user 1058368 May 3 07:23 stm.elf
Which STM chip (and maybe demo card) are you using?STM32F411: flash at 0 to 0x8000000, ram at 0x2000000 to 0x2002000. >>>>>>
What are the memory ranges you want?
If i use .org 0x2000000 for .data and .bss. Every ROM image is at least 33Mbytes.
I am just avoiding globals for now. But someone must have solved this problem somewhere.
Sorry,
STM32F411: flash at 0 to 0x80000, ram at 0x20000000 to 0x20020000.
The way to feed the linker script is the compiler switch
-Wl,-T,myscript.ld
If you put this in gcc-cc command, it will pass it to gcc-ld, gcc-as will not accept this option. So, gcc-as put global variables at 0x0p and linker put them at 0x2000p (p=page of 0x0000 bytes).
There is a good reason to add -Wl,-Map=myfile.map
to the compiler switches to see what the linker has done.
Please get the compiler and linker manuals and read them.
To set up the runtime system, you need a routine at the very
start to copy the initial values from the ROM to the RAM for
the .data section.
Yes, and the assembler need to know to compile codes for address 0x2000p but put it near 0x0p. It's currently ignoring the linking instructions.
If i use ".text .org 0x100, .data .org 0x2000p and.bss .org 0x2001p", it create a 500 Mbytes file with holes (zeros). So, i need to punch it out for the rom image.
,bss is technically incorrect, because it is saying to zero out all memory between 0x0p and 0x2001p, but at least it doesn't do anything and doesn't take up any storage space.
punch stm.xlf
Section Address Offset Size
.text 00000000 00000034 00000a10 fe ff ff ea 04 b0 2d e5
.data 00000000 00000a44 20000004 78 56 34 12 fa 3f 00 20
.bss 00000000 20010a48 20010004
.rodata 00000000 20010a48 00000048 fa 3f 00 20 04 01 00 00
punch stm.elf stm.xlf
Section Address Offset Size
.text 00000100 00000034 00000910 fe ff ff ea 04 b0 2d e5
.data 20000000 e0000a44 00000004 78 56 34 12
.bss 20010000 00000a48 00000004
.rodata 00000000 00001a48 00000048 fa 3f 00 20 04 01 00 00
punch rewrite the elf sections when a third argument is provided.
correct it. If you're using GCC to assemble a .s or .S file, the
normal switches apply.
user@user:~/mcu$ arm-none-eabi-gcc -g -Wall -nostdlib main.s -T stm.ld
user@user:~/mcu$ arm-none-eabi-as -g main.s -T stm.ld
arm-none-eabi-as: unrecognized option '-T'
user@user:~/mcu$ arm-none-eabi-ld main.o -T stm.ld
There is a good reason to use the assembler only to create the .o file
and make the linking in a separate step (using gcc again).
Please remove the .org directives from your assembler code. The linker
script is the proper way to locate various program sections. If you
But gcc-as generates the wrong addresses with memory access.
want to have a piece of code or data located separately, create an
own section for the blob and tell the linker where it's wanted to go.
For an example, see the section .romvec in the linker script.
What is punch? A STM weirdness?
Punch is a custom program to reduce the holely file by mmu instructions from the project. This still require an intermediate 500M bytes file to generate the virtual address sections, then map to the physical address sections. Of course, the proper
mmu instructions:
.rodata 0 to 0x100 (boot and interrupt vectors)
.text 0x100 to 0x2000p
.data 0x2000p to 0x2001p
.bss 0x2001p to 0x2002p
Please show the exact command line you're using for the as, so we can
correct it. If you're using GCC to assemble a .s or .S file, the
normal switches apply.
user@user:~/mcu$ arm-none-eabi-gcc -g -Wall -nostdlib main.s -T stm.ld
user@user:~/mcu$ arm-none-eabi-as -g main.s -T stm.ld
arm-none-eabi-as: unrecognized option '-T'
user@user:~/mcu$ arm-none-eabi-ld main.o -T stm.ld
There is a good reason to use the assembler only to create the .o file
and make the linking in a separate step (using gcc again).
Please remove the .org directives from your assembler code. The linker
script is the proper way to locate various program sections. If you
But gcc-as generates the wrong addresses with memory access.
way to do it is to patch gcc with the mmu instructions.want to have a piece of code or data located separately, create an
own section for the blob and tell the linker where it's wanted to go.
For an example, see the section .romvec in the linker script.
What is punch? A STM weirdness?
Punch is a custom program to reduce the holely file by mmu instructions from the project. This still require an intermediate 500M bytes file to generate the virtual address sections, then map to the physical address sections. Of course, the proper
mmu instructions:
.rodata 0 to 0x100 (boot and interrupt vectors)
.text 0x100 to 0x2000p
.data 0x2000p to 0x2001p
.bss 0x2001p to 0x2002p
On Tuesday, May 4, 2021 at 7:44:05 AM UTC-7, Tauno Voipio wrote:
On 4.5.21 16.32, Ed Lee wrote:
On Tuesday, May 4, 2021 at 2:38:55 AM UTC-7, Tauno Voipio wrote:
On 3.5.2021 22:14 PM, Ed Lee wrote:
On Monday, May 3, 2021 at 12:12:53 PM UTC-7, Ed Lee wrote:
On Monday, May 3, 2021 at 11:49:42 AM UTC-7, Tauno Voipio wrote:
On 3.5.21 17.35, Ed Lee wrote:
What is the compiler option and/or directive to change the "Addr" field of elf file?
Please show the exact command line you're using for the as, so we can correct it. If you're using GCC to assemble a .s or .S file, the
normal switches apply.
user@user:~/mcu$ arm-none-eabi-gcc -g -Wall -nostdlib main.s -T stm.ld
user@user:~/mcu$ arm-none-eabi-as -g main.s -T stm.ld
arm-none-eabi-as: unrecognized option '-T'
user@user:~/mcu$ arm-none-eabi-ld main.o -T stm.ld
There is a good reason to use the assembler only to create the .o file
and make the linking in a separate step (using gcc again).
Please remove the .org directives from your assembler code. The linker script is the proper way to locate various program sections. If you
But gcc-as generates the wrong addresses with memory access.
Ed Lee <edward....@gmail.com> wrote:
On Tuesday, May 4, 2021 at 7:44:05 AM UTC-7, Tauno Voipio wrote:
On 4.5.21 16.32, Ed Lee wrote:
On Tuesday, May 4, 2021 at 2:38:55 AM UTC-7, Tauno Voipio wrote:Please show the exact command line you're using for the as, so we can correct it. If you're using GCC to assemble a .s or .S file, the
On 3.5.2021 22:14 PM, Ed Lee wrote:
On Monday, May 3, 2021 at 12:12:53 PM UTC-7, Ed Lee wrote:
On Monday, May 3, 2021 at 11:49:42 AM UTC-7, Tauno Voipio wrote: >>>>> On 3.5.21 17.35, Ed Lee wrote:
What is the compiler option and/or directive to change the "Addr" field of elf file?
normal switches apply.
user@user:~/mcu$ arm-none-eabi-gcc -g -Wall -nostdlib main.s -T stm.ldLooks OK
user@user:~/mcu$ arm-none-eabi-as -g main.s -T stm.ld
arm-none-eabi-as: unrecognized option '-T'
user@user:~/mcu$ arm-none-eabi-ld main.o -T stm.ldGiven correct main.o shoud be OK.
There is a good reason to use the assembler only to create the .o file and make the linking in a separate step (using gcc again).
Please remove the .org directives from your assembler code. The linker script is the proper way to locate various program sections. If you
But gcc-as generates the wrong addresses with memory access.If you write correct asm your addresses will be correct.
Look at following:
----------------<cut here>--------------------
.syntax unified
.cpu cortex-m4
.text
.Lstack:
.word 0x20020000
.Lstart:
.word start
.text
.org 512
.global start
.thumb
.thumb_func
.type start, %function
start:
ldr r2, .L4
.L2:
ldr r3, [r2]
adds r3, r3, #1
str r3, [r2]
b .L2
.align 2
.L4:
.word c
.comm c,4,4
----------------<cut here>--------------------
Store to anull.s and do:
arm-none-eabi-as -c anull.s -o anull.o
arm-none-eabi-ld anull.o -T f411.ld -o anull.elf
AFAICS it generates .elf file as you want. There is little
weirdness with interrupt vectors: Tauno Voipio wanted vectors
in separate section but I normally put them in .text,
so using his linker script with my asm gives empty .romvec.
Above I put just two vectors (should be enough to run) but
in something serious there would be a subsection (written
in C).
--
Waldek Hebisch
AFAICS it generates .elf file as you want. There is little
weirdness with interrupt vectors: Tauno Voipio wanted vectors
in separate section but I normally put them in .text,
so using his linker script with my asm gives empty .romvec.
Above I put just two vectors (should be enough to run) but
in something serious there would be a subsection (written
in C).
Ed Lee <edward....@gmail.com> wrote:
On Tuesday, May 4, 2021 at 12:22:16 PM UTC-7, anti...@math.uni.wroc.pl wrote:
Ed Lee <edward....@gmail.com> wrote:
On Tuesday, May 4, 2021 at 7:44:05 AM UTC-7, Tauno Voipio wrote:
On 4.5.21 16.32, Ed Lee wrote:
On Tuesday, May 4, 2021 at 2:38:55 AM UTC-7, Tauno Voipio wrote:Please show the exact command line you're using for the as, so we can correct it. If you're using GCC to assemble a .s or .S file, the normal switches apply.
On 3.5.2021 22:14 PM, Ed Lee wrote:
On Monday, May 3, 2021 at 12:12:53 PM UTC-7, Ed Lee wrote:
On Monday, May 3, 2021 at 11:49:42 AM UTC-7, Tauno Voipio wrote: >>>>> On 3.5.21 17.35, Ed Lee wrote:
What is the compiler option and/or directive to change the "Addr" field of elf file?
user@user:~/mcu$ arm-none-eabi-gcc -g -Wall -nostdlib main.s -T stm.ldLooks OK
user@user:~/mcu$ arm-none-eabi-as -g main.s -T stm.ld
arm-none-eabi-as: unrecognized option '-T'
user@user:~/mcu$ arm-none-eabi-ld main.o -T stm.ldGiven correct main.o shoud be OK.
There is a good reason to use the assembler only to create the .o file
and make the linking in a separate step (using gcc again).
Please remove the .org directives from your assembler code. The linker
script is the proper way to locate various program sections. If you
But gcc-as generates the wrong addresses with memory access.If you write correct asm your addresses will be correct.
Look at following:
----------------<cut here>--------------------
.syntax unified
.cpu cortex-m4
.text
.Lstack:
.word 0x20020000
.Lstart:
.word start
.text
.org 512
.global start
.thumb
.thumb_func
.type start, %function
start:
ldr r2, .L4
r2 = 550 (aprox)Wrong, this is PC relative load that load value stored at .L4,
that is 0x20000000 (address of c).
On Tuesday, May 4, 2021 at 12:22:16 PM UTC-7, anti...@math.uni.wroc.pl wrote:
Ed Lee <edward....@gmail.com> wrote:
On Tuesday, May 4, 2021 at 7:44:05 AM UTC-7, Tauno Voipio wrote:
On 4.5.21 16.32, Ed Lee wrote:
On Tuesday, May 4, 2021 at 2:38:55 AM UTC-7, Tauno Voipio wrote:Please show the exact command line you're using for the as, so we can correct it. If you're using GCC to assemble a .s or .S file, the
On 3.5.2021 22:14 PM, Ed Lee wrote:
On Monday, May 3, 2021 at 12:12:53 PM UTC-7, Ed Lee wrote:
On Monday, May 3, 2021 at 11:49:42 AM UTC-7, Tauno Voipio wrote: >>>>> On 3.5.21 17.35, Ed Lee wrote:
What is the compiler option and/or directive to change the "Addr" field of elf file?
normal switches apply.
user@user:~/mcu$ arm-none-eabi-gcc -g -Wall -nostdlib main.s -T stm.ldLooks OK
user@user:~/mcu$ arm-none-eabi-as -g main.s -T stm.ld
arm-none-eabi-as: unrecognized option '-T'
user@user:~/mcu$ arm-none-eabi-ld main.o -T stm.ldGiven correct main.o shoud be OK.
There is a good reason to use the assembler only to create the .o file and make the linking in a separate step (using gcc again).
Please remove the .org directives from your assembler code. The linker script is the proper way to locate various program sections. If you
But gcc-as generates the wrong addresses with memory access.If you write correct asm your addresses will be correct.
Look at following:
----------------<cut here>--------------------
.syntax unified
.cpu cortex-m4
.text
.Lstack:
.word 0x20020000
.Lstart:
.word start
.text
.org 512
.global start
.thumb
.thumb_func
.type start, %function
start:
ldr r2, .L4
r2 = 550 (aprox)
.L2:
ldr r3, [r2]
r3 = c
adds r3, r3, #1
r3 = d
str r3, [r2]
store d to memory location 550
Segmentation violation. Can't write to ROM.
b .L2
.align 2
.L4:
.word c
.comm c,4,4
----------------<cut here>--------------------
Store to anull.s and do:
arm-none-eabi-as -c anull.s -o anull.o
arm-none-eabi-ld anull.o -T f411.ld -o anull.elf
AFAICS it generates .elf file as you want. There is little
weirdness with interrupt vectors: Tauno Voipio wanted vectors
in separate section but I normally put them in .text,
so using his linker script with my asm gives empty .romvec.
Above I put just two vectors (should be enough to run) but
in something serious there would be a subsection (written
in C).
--
Waldek Hebisch
On 5/4/2021 12:22 PM, antispam@math.uni.wroc.pl wrote:
AFAICS it generates .elf file as you want. There is little
weirdness with interrupt vectors: Tauno Voipio wanted vectors
in separate section but I normally put them in .text,
so using his linker script with my asm gives empty .romvec.
Above I put just two vectors (should be enough to run) but
in something serious there would be a subsection (written
in C).
In general (since forever) you can't go wrong with MORE sections.
This makes the layout of the code visible to the link/load phase.
I put the *ROM* copy of vectors in one section and the *RAM*
copy in another (as the code will switch to the RAM copy once
the ROM image has been verified and RAM initialized, program
loaded, etc.).
Likewise, the boot loader, BIST, etc.
This lets you juggle where things should "fit" in the final image
instead of having to examine the code, itself, to determine the
structure. The tools are already there; let them do the work.
[It also makes it easier to reuse "sections" from one project
to the next]
Don Y <blockedofcourse@foo.invalid> wrote:
On 5/4/2021 12:22 PM, antispam@math.uni.wroc.pl wrote:
AFAICS it generates .elf file as you want. There is little
weirdness with interrupt vectors: Tauno Voipio wanted vectors
in separate section but I normally put them in .text,
so using his linker script with my asm gives empty .romvec.
Above I put just two vectors (should be enough to run) but
in something serious there would be a subsection (written
in C).
In general (since forever) you can't go wrong with MORE sections.
This makes the layout of the code visible to the link/load phase.
I put the *ROM* copy of vectors in one section and the *RAM*
copy in another (as the code will switch to the RAM copy once
the ROM image has been verified and RAM initialized, program
loaded, etc.).
Likewise, the boot loader, BIST, etc.
You probably imagine something more complicated than STM32F411.
This lets you juggle where things should "fit" in the final image
instead of having to examine the code, itself, to determine the
structure. The tools are already there; let them do the work.
[It also makes it easier to reuse "sections" from one project
to the next]
The example is a toy which IMO fulfils its purpose. As I wrote
I have vectors as subsection, in linker script I can put it
where I want it, simply to the moment it was most convenient
to put it in .text. With my setup I can link .text so that
it goes to RAM, which is convenient for debugging small programs
or to ROM (usual setup). Script provided by Tauno Voipio
creates overlapped sections in final executable, I do not
know why. I can imagine use of overlapped sections in RAM,
but what they buy in ROM?
Personaly, I am trying to avoid unnecessary complexity.
Currently linker scripts give me enough possibilities
to rearrange code, so I felt no need to additionally
juggle sections in executable (that would be different
if an OS was present, but I am talking here about
programs running on bare hardware).
On Tuesday, May 4, 2021 at 3:57:23 PM UTC-7, anti...@math.uni.wroc.pl wrote:
Ed Lee <edward....@gmail.com> wrote:
On Tuesday, May 4, 2021 at 12:22:16 PM UTC-7, anti...@math.uni.wroc.pl wrote:
Ed Lee <edward....@gmail.com> wrote:
On Tuesday, May 4, 2021 at 7:44:05 AM UTC-7, Tauno Voipio wrote:
On 4.5.21 16.32, Ed Lee wrote:
On Tuesday, May 4, 2021 at 2:38:55 AM UTC-7, Tauno Voipio wrote:Please show the exact command line you're using for the as, so we can
On 3.5.2021 22:14 PM, Ed Lee wrote:
On Monday, May 3, 2021 at 12:12:53 PM UTC-7, Ed Lee wrote:
On Monday, May 3, 2021 at 11:49:42 AM UTC-7, Tauno Voipio wrote:
On 3.5.21 17.35, Ed Lee wrote:
What is the compiler option and/or directive to change the "Addr" field of elf file?
correct it. If you're using GCC to assemble a .s or .S file, the normal switches apply.
user@user:~/mcu$ arm-none-eabi-gcc -g -Wall -nostdlib main.s -T stm.ldLooks OK
user@user:~/mcu$ arm-none-eabi-as -g main.s -T stm.ld arm-none-eabi-as: unrecognized option '-T'
user@user:~/mcu$ arm-none-eabi-ld main.o -T stm.ldGiven correct main.o shoud be OK.
There is a good reason to use the assembler only to create the .o file
and make the linking in a separate step (using gcc again).
Please remove the .org directives from your assembler code. The linker
script is the proper way to locate various program sections. If you
But gcc-as generates the wrong addresses with memory access.If you write correct asm your addresses will be correct.
Look at following:
----------------<cut here>--------------------
.syntax unified
.cpu cortex-m4
.text
.Lstack:
.word 0x20020000
.Lstart:
.word start
.text
.org 512
.global start
.thumb
.thumb_func
.type start, %function
start:
ldr r2, .L4
r2 = 550 (aprox)Wrong, this is PC relative load that load value stored at .L4,
that is 0x20000000 (address of c).
PC is approx 520. The assembler does not know about 0x20000000.
Ed Lee <edward....@gmail.com> wrote:
On Tuesday, May 4, 2021 at 3:57:23 PM UTC-7, anti...@math.uni.wroc.pl wrote:
Ed Lee <edward....@gmail.com> wrote:
On Tuesday, May 4, 2021 at 12:22:16 PM UTC-7, anti...@math.uni.wroc.pl wrote:
Ed Lee <edward....@gmail.com> wrote:
On Tuesday, May 4, 2021 at 7:44:05 AM UTC-7, Tauno Voipio wrote:
On 4.5.21 16.32, Ed Lee wrote:
On Tuesday, May 4, 2021 at 2:38:55 AM UTC-7, Tauno Voipio wrote:Please show the exact command line you're using for the as, so we can
On 3.5.2021 22:14 PM, Ed Lee wrote:
On Monday, May 3, 2021 at 12:12:53 PM UTC-7, Ed Lee wrote: >>>> On Monday, May 3, 2021 at 11:49:42 AM UTC-7, Tauno Voipio wrote:
On 3.5.21 17.35, Ed Lee wrote:
What is the compiler option and/or directive to change the "Addr" field of elf file?
correct it. If you're using GCC to assemble a .s or .S file, the normal switches apply.
user@user:~/mcu$ arm-none-eabi-gcc -g -Wall -nostdlib main.s -T stm.ldLooks OK
user@user:~/mcu$ arm-none-eabi-as -g main.s -T stm.ld arm-none-eabi-as: unrecognized option '-T'
user@user:~/mcu$ arm-none-eabi-ld main.o -T stm.ldGiven correct main.o shoud be OK.
There is a good reason to use the assembler only to create the .o file
and make the linking in a separate step (using gcc again).
Please remove the .org directives from your assembler code. The linker
script is the proper way to locate various program sections. If you
But gcc-as generates the wrong addresses with memory access.If you write correct asm your addresses will be correct.
Look at following:
----------------<cut here>--------------------
.syntax unified
.cpu cortex-m4
.text
.Lstack:
.word 0x20020000
.Lstart:
.word start
.text
.org 512
.global start
.thumb
.thumb_func
.type start, %function
start:
ldr r2, .L4
r2 = 550 (aprox)Wrong, this is PC relative load that load value stored at .L4,
that is 0x20000000 (address of c).
PC is approx 520. The assembler does not know about 0x20000000.Have you tried provided commands? There is also objdump, run
arm-none-eabi-objdump -D anull.elf
to see what is in .elf file. And compare with
arm-none-eabi-objdump -D anull.o
And yes, assember produces relocatable code and does not know
addresses. It is linker job to put addresses into ELF executable.
I am just trying to convince myself how is that possible to work without the assembler knowing the actual physical address of ram.
On 5/4/2021 6:06 PM, Ed Lee wrote:
I am just trying to convince myself how is that possible to work without the"RAM" is just a set of one (or more) labels that you have located in a data segment.
assembler knowing the actual physical address of ram.
How does the assembler know how to access a subroutine that you've defined IN
ANOTHER MODULE?
On Tuesday, May 4, 2021 at 6:26:44 PM UTC-7, Don Y wrote:
On 5/4/2021 6:06 PM, Ed Lee wrote:
I am just trying to convince myself how is that possible to work without >>> the assembler knowing the actual physical address of ram."RAM" is just a set of one (or more) labels that you have located in a
data segment.
How does the assembler know how to access a subroutine that you've defined >> IN ANOTHER MODULE?
The compiler tell the linker to relocate address of another module, as well as address of data variables. But it does not change the content of such variables, even if they are relocated to another address space. In this case, if the assembler is using the content of the variable pointing to the data variable's address, it would remain in the rom space.
On Tuesday, May 4, 2021 at 6:26:44 PM UTC-7, Don Y wrote:using the content of the variable pointing to the data variable's address, it would remain in the rom space.
On 5/4/2021 6:06 PM, Ed Lee wrote:
I am just trying to convince myself how is that possible to work without the"RAM" is just a set of one (or more) labels that you have located in a data segment.
assembler knowing the actual physical address of ram.
How does the assembler know how to access a subroutine that you've defined IN
ANOTHER MODULE?
The compiler tell the linker to relocate address of another module, as well as address of data variables. But it does not change the content of such variables, even if they are relocated to another address space. In this case, if the assembler is
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 293 |
Nodes: | 16 (2 / 14) |
Uptime: | 221:53:50 |
Calls: | 6,623 |
Calls today: | 5 |
Files: | 12,171 |
Messages: | 5,318,103 |