This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

ld changing section names with attr "a" (ALLOC)


I'm facing a peculiar problem (might be a feature, don't know)
where linker changes the name of user defined section.
"GNU ld version 2.13.1" Cross-compiled for MIPS on x86.

I define section in assembly source as:
.section .new_section,"ax",@progbits

I assemble [1] and then link with 2 diff methods,
with my own linker script[2] and with section address
in command line[3]

[1] mips-elf-as test.s -o test.o
[2] mips-elf-ld -T m1.lk test.o -o test_wls.exe
            OR
[3] mips-elf-ld --section-start .new_section=0x8000 test.o -o
test_cmdline.exe

I case of command [3] I see that linker adds the suffix ".1"
to the my new section name:
(and does *not* place it at the address I want)

------------------------------------------------
test_cmdline.exe:     file format elf32-bigmips
Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .new_section  00000000  00008000  00008000  00001024  2**0
                  CONTENTS
------ snip ----->
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  4 .new_section.1 0000000c  00400018  00400018  00001018  2**0
                ^^^         ^^^^^^^^^^
                  CONTENTS, ALLOC, LOAD, READONLY, CODE

Whereas this is NOT the case when I use the linker script:

------------------------------------------------
test_wls.exe:     file format elf32-bigmips
Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .new_section  0000000c  00000800  00000800  00001800  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, CODE


Additional note: I notice this happen *ONLY* when I set
the "a" bit for section, i.e. when I have section defined as
.section .new_section,"x",@progbits
linker doesn't play with names, but then that section
is not disassembled with 'objdump -D' option!

In short my requirement is I want to define a section
that holds code (ALLOC, CODE bit set) and should be able
to specify the section start address on *command line*

I looked through manual and web, but in vain.  Am I
missing something?  I'm attaching the files I used, please help.

TIA.

Regards,
Atul P Talesara 
---------------------------------------------
Everyone wants to save the world,
But no one wants to help mumma with dishes!
---------------------------------------------

Attachment: test.s
Description: test.s

Attachment: m1.lk
Description: m1.lk


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]