LMA and VMA never change when i link the object

Asked by weiguixm

i wrote a super simple a.S and compile using the following commands:
arm-none-eabi-as a.S -o a.o
arm-none-eabi-ld -T a.lds a.o -o a.elf

I find that the address of a.elf is always 0x0 althouth i have assigned it to 0x30000000. And i have tried all measures i know to change its address but failed. Just want to know where the problem is or what i have missed. By the way, I've tried under gcc for x86 with the same measure and it worked normal.

[content of a.S]
.global _start

.section text
_start:
        b _start

[content of a.lds:]
ENTRY(_start)
SECTIONS
{
        . = 0x30000000;
        .text : AT(0x30000000)
         {
                *(.text)
         }
        .data : ALIGN(0x1000)
                {*(.data)}

        .bss : {*(.bss)}
}

[output of arm-none-eabi-objdump -D a.elf]
a.elf: file format elf32-littlearm
Disassembly of section text:
00000000 <_start>:
   0: eafffffe b 0 <_start>

Question information

Language:
English Edit question
Status:
Solved
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Solved by:
Thomas Preud'homme
Solved:
Last query:
Last reply:
Revision history for this message
Best Thomas Preud'homme (thomas-preudhomme) said :
#1

Hi Weiguixm,

There is a typo in your assembly file: you should write .section .text (note the dot before text). Then it works as expected. Note that by default the LMA is identical to VMA so no need to specify it. As to the VMA, I prefer to specify memory regions rather than set the location counter, even when there is only one memory region (but that's just a matter of preference).

Best regards.

Revision history for this message
weiguixm (623674292-c) said :
#2

Thanks Thomas Preud'homme, that solved my question.

Revision history for this message
weiguixm (623674292-c) said :
#3

Dear Thomas,
Thank you for your help very much. I'm a begginer to gcc tools, and i'll check how to specify memory regions you mentioned.
Can't be more thank to you.

------------------ 原始邮件 ------------------
发件人: "Thomas Preud'homme"<email address hidden>;
发送时间: 2015年8月28日(星期五) 中午1:41
收件人: "发面"<email address hidden>;
主题: Re: [Question #270847]: LMA and VMA never change when i link theobject

Your question #270847 on GCC ARM Embedded changed:
https://answers.launchpad.net/gcc-arm-embedded/+question/270847

    Status: Open => Answered

Thomas Preud'homme proposed the following answer:
Hi Weiguixm,

There is a typo in your assembly file: you should write .section .text
(note the dot before text). Then it works as expected. Note that by
default the LMA is identical to VMA so no need to specify it. As to the
VMA, I prefer to specify memory regions rather than set the location
counter, even when there is only one memory region (but that's just a
matter of preference).

Best regards.

--
If this answers your question, please go to the following page to let us
know that it is solved:
https://answers.launchpad.net/gcc-arm-embedded/+question/270847/+confirm?answer_id=0

If you still need help, you can reply to this email or go to the
following page to enter your feedback:
https://answers.launchpad.net/gcc-arm-embedded/+question/270847

You received this question notification because you asked the question.

Revision history for this message
Thomas Preud'homme (thomas-preudhomme) said :
#4

Hi Weiguixm,

You can find the documentation on how to specify memory regions at [1] and some example on how it's used in our gcc.ld sample in our share/gcc-arm-none-eabi/samples/ldscripts subdirectory.

[1] https://sourceware.org/binutils/docs-2.24/ld/MEMORY.html#MEMORY

Best regards.