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

Atul Talesara atul.talesara@nevisnetworks.com
Fri Jul 23 11:26:00 GMT 2004


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!
---------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.s
Type: application/octet-stream
Size: 445 bytes
Desc: test.s
URL: <https://sourceware.org/pipermail/binutils/attachments/20040723/f74525c7/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: m1.lk
Type: application/octet-stream
Size: 236 bytes
Desc: m1.lk
URL: <https://sourceware.org/pipermail/binutils/attachments/20040723/f74525c7/attachment-0001.obj>


More information about the Binutils mailing list