This is the mail archive of the binutils@sourceware.org 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]

Re: GAS: changing name of default sections .text/.data/.rodata


--- Erik Christiansen <erik@dd.nec.com.au> wrote:
> Yes, all those __attribute_ occurrences quickly become a pain.
> Could you not use the linker's native action of mapping input
> sections to output sections? i.e. in the linker script:
> 
> .code16 : { *(.text) } > here
> .data16 : { *(.data) } > there
> .rodata16 : { *(.rodata) } > elsewhere
> 
> Then all the default stuff acquires the desired section names
> in the ELF output.
> 
> (Now I'm wondering what part of the problem I've missed. :-)

  The problem is that all objects of the directory
Linux/arch/i386/kernel/ are pre-linked together by a simple
"ld -R *.o" command in a Makefile, so the final linker file
cannot even do " .code16: { realmode.o(.text) } > here ",
there is just one big ".text" for all protected mode code.

 In the patch (which produces a working Linux kernel) I gave:
http://marc.theaimsgroup.com/?l=linux-kernel&m=113650255604862&q=p3
 you can see nearby the middle the modification of the
vmlinux.lds.S linker file I did, that was quite simple
because nothing was mapped at load address zero.

 There is no real risk of mixing symbols in between sections
because of the NOCROSSREFS() of the link file.

 To remove all those __attribute__((section())) from the C
real mode source code of the patch, the best solution would
be objcopy, but that imply creating an intermediate file
and treating realmode.c in a way difficult to do in Makefile.

 The next best solution would be an option of GAS to append
some string to all section created, then I can add in Makefile
a special CFLAGS for realmode.o (I did not test it lately but
I think it is quite simple, something like:
$(obj)/realmode.o: CFLAGS += -Wa,-postsection="16" )

 Another simple solution is something added in the assembler
file itself to prepend all section names with a string like
"16" to get ".text16", ".bss16", ".rodata*16" - maybe only
when ".code16gcc" is used. That solution is a bit complex
because ".text", ".bss" and ".data" are treated as keywords but
".rodata" is just a section name and shall be used with the
keyword ".section".

 The latter solution would be the simpler for me, but because
Gujin is fully GPL, I can adapt to any solution...

 Note that I did not explore that much a solution where the
file realmode.c is first compiled to a realmode.S file, then
a sed script is done to produce a realmode.s file, then a
realmode.o is generated by GAS. I am not sure it would be
considered "clean" by the Linux kernel people.

  Etienne.


	

	
		
___________________________________________________________________________ 
Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.
Téléchargez sur http://fr.messenger.yahoo.com


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