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


  Hi Nick,

> >  For instance, part of the Linux patch (WEB link I gave) in
> > arch/i386/kernel/Makefile:
> >  obj-y	:= process.o semaphore.o signal.o entry.o traps.o irq.o \
> >      ptrace.o time.o ioport.o ldt.o setup.o i8259.o sys_i386.o \
> >      pci-dma.o i386_ksyms.o i387.o dmi_scan.o bootflag.o \
> > -    quirks.o i8237.o i8253.o tsc.o
> > +    quirks.o i8237.o i8253.o tsc.o realmode.o
> > 
> ......
> >  Moreover, in this case, the file realmode.o is pre-linked
> > in "arch/i386/kernel/built-in.o" so the Makefile rule to obtain
> > realmode.o from realmode.c has to be special involving an added
> > objcopy, and so another file extension for the intermediate file.
> 
> Are you saying that the Makefile already has an intermediate step that 
> runs objcopy as part of the process to create realmode.o ?  If so, what 
> is hard about adding a second objcopy step (or an augmented first 
> objcopy step) to rename the sections in the manner you desire ?

  No, there is no objcopy used to generate each intermediate libraries
 in each subdirectories arch/i386/*/built-in.o, just "gcc -c *.c" and "ld -R *.o".
 The Linux patch I proposed on LKM is replacing a subdirectory full of assembler
 by one C file named realmode.c - so this file is new in linux source.

 Of the list of files in Makefile variable-list obj-y, only one file shall
 be compiled for i386 real mode (with .code16gcc): realmode.c, the others
 source files are i386 protected mode (i.e. 32 bits addressing).
 So the section ".text", ".data", ".rodata" and ".bss" of realmode.o shall
 not be mixed with those of the other files: they have to go in their own
 linker sections mapped at load address 0.

> >  And the process to obtain built-in.o is common to all
> > subdirectory so I cannot add a test for just a file.
> 
> But you can add a special rule to the Makefile to handle it.
> 
> So for example you could change the objects list in the Makefile to 
> rename built-in.o to mangled-built-in.o and then make a make rule like this:
> 
>    mangled-built-in.o: builtin.o
>     objcopy --rename-section .text=.text16 built-in.o mangled-built-in.o
> 
> Wouldn't this work ?

  It may work at the "build realmode.o" level, once built-in.o is generated
 by "ld -R *.o" there is just one big ".text" section.
 The problem is that I have to disable Makefile rule to generate realmode.o
 from realmode.c (%.o: %.c ...), probably by doing in Makefile:

$(obj)/realmode.o: realmode.c
    gcc <options> -o $(obj)/realmode.obj realmode.c
    objcopy $(obj)/realmode.obj $(obj)/realmode.o --rename-section .text=.text16

 I usually do not do this because if this Makefile rule is lost in an include file
 and not applied in some case the default rule is applied and the error messages
 are quite unrelated. If someone knowns a Makefile trick to add a make-step for
 one file only, while keeping the same source file/extension and the same
 object/extension I would like to know about it.

 Maybe the main problem is that I want to simplify Linux generation by just making
one link (containning real mode and protected mode code) instead of two links (one
for real mode and one for protected mode) and then concatenate the two files.
 The only problem I have for that is the section names when compiling things with
".code16gcc": the real mode and protected mode sections have to be linked at different
addresses.
 The option I have taken up to now is to give attribute((section())) to each symbols
(variable or function) in file realmode.c .  That has the advantage that in the long
term, the functions like "probe_video_bios_information()" may move to the video
subdirectory with those same attributes - and so no more file containning everything
executed in real mode (so types/structures filed-in declared locally in the source file).
 That has the disadvantage that unnamed symbols like initialisation strings or switch
jump array cannot exist because you cannot set a section for those.
 I am under the impression that my solution does not produce clean enough code for
a patch to Linux - so maybe a single realmode.c without __attribute__(()) would be
accepted. For that it is quite difficult to use objcopy - unless there is a trick
I am not aware of in Makefile.

  Cheers,
  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]