реклама на сайте
подробности

 
 
> Не понимаю окончательно работу GNU линкера, Секция линкуется, но мне не понятно, почему,
haker_fox
сообщение Jan 9 2012, 09:05
Сообщение #1


Познающий...
******

Группа: Свой
Сообщений: 2 963
Регистрация: 1-09-05
Из: г. Иркутск
Пользователь №: 8 125



Здравствуйте, уважаемые коллеги!
Решил углубить знания по линкеру. Нужно rolleyes.gif Имеется следующий код
CODE
.section     .text
.code 32


    LDR        PC,        =0x40004000


.section    .data
data1:        .word    0x89ABCDEF

.section    .bss
bss1:        .word    0

.section    .fox, "ax"
    NOP
    NOP
    NOP
    NOP
    BX        LR

и скрипт линкера
CODE
MEMORY
{
    RAM(RW)        :    org = 0x40000000, len = 32K
    RAMOV(RW)    :    org = 0x40004000, len = 4K
}

SECTIONS
{
    .text : { *.(text) } > RAM
    .data : { *.( data ) } > RAM
    .bss  : { *.( bss ) } > RAM
    
    .fox  : { *(.fox .fox*) } > RAMOV
    
}

Трансляция кода идет следующим образом
CODE
arm-kgp-elf-as -mcpu=arm7tdmi-s test.s -o test.o
arm-kgp-elf-ld test.o -o test.elf -Ttest.ld

В этом случае все собирается отлично. В эльфе все необходимые секции.
Стоит секцию .fox пометить только флагом "x" в исходнике на языке ассемблера, как она перестает линковаться. Я не понимаю почему это происходит? Документация говорить, что флаг "a" - это перемещаемая (allocatable) секция.
Но нигде не могу найти описания, для чего секции дается такой статус? Почему секцию просто нельзя пометить "xw", например? Да, стандартные секции .text, .data и .bss линкуются всегда...
Буду благодарен за любую информацию!

З.Ы. МК LPC2468.
Спасибо!


--------------------
Выбор.
Go to the top of the page
 
+Quote Post
 
Start new topic
Ответов
ReAl
сообщение Jan 10 2012, 11:34
Сообщение #2


Нечётный пользователь.
******

Группа: Свой
Сообщений: 2 033
Регистрация: 26-05-05
Из: Бровари, Україна
Пользователь №: 5 417



Цитата(haker_fox @ Jan 9 2012, 11:05) *
Документация говорить, что флаг "a" - это перемещаемая (allocatable) секция.
Что-то мне кажется, что это означает не «перемещаемая», а «размещаемая», «занимающая место в бинарнике». В отличие от, скажем, .bss.


--------------------
Ну, я пошёл… Если что – звоните…
Go to the top of the page
 
+Quote Post
am1808
сообщение Jan 10 2012, 11:44
Сообщение #3


Частый гость
**

Группа: Участник
Сообщений: 125
Регистрация: 29-05-11
Из: Nizhny Novgorod, Russian Federation
Пользователь №: 65 337



могу ошибаться, но
данная секция в любом случае будет allocatable,
за исключением случаев, когда этот код будет выполняться с ROM

Цитата(ReAl @ Jan 10 2012, 15:34) *
Что-то мне кажется, что это означает не «перемещаемая», а «размещаемая», «занимающая место в бинарнике». В отличие от, скажем, .bss.


Locations represent addresses in memory if a section is allocatable; that is, its
contents are to be placed in memory at program runtime. Symbolic references
to these locations must be changed to addresses by the link editor.

еще может быть полезным:

The linker combines input files into a single output file. The output file and each input file are in a special data format known as an object file format. Each file is called an object file. The output file is often called an executable, but for our purposes we will also call it an object file. Each object file has, among other things, a list of sections. We sometimes refer to a section in an input file as an input section; similarly, a section in the output file is an output section.

Each section in an object file has a name and a size. Most sections also have an associated block of data, known as the section contents. A section may be marked as loadable, which mean that the contents should be loaded into memory when the output file is run. A section with no contents may be allocatable, which means that an area in memory should be set aside, but nothing in particular should be loaded there (in some cases this memory must be zeroed out). A section which is neither loadable nor allocatable typically contains some sort of debugging information.

Every loadable or allocatable output section has two addresses. The first is the VMA, or virtual memory address. This is the address the section will have when the output file is run. The second is the LMA, or load memory address. This is the address at which the section will be loaded. In most cases the two addresses will be the same. An example of when they might be different is when a data section is loaded into ROM, and then copied into RAM when the program starts up (this technique is often used to initialize global variables in a ROM based system). In this case the ROM address would be the LMA, and the RAM address would be the VMA.

Сообщение отредактировал am1808 - Jan 10 2012, 12:10
Go to the top of the page
 
+Quote Post



Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 31st July 2025 - 16:32
Рейтинг@Mail.ru


Страница сгенерированна за 0.01395 секунд с 7
ELECTRONIX ©2004-2016