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]

Re: [PATCH] SHF_MERGE support for gas and ld (was RFC: .gnu.strtab ...)


On Mon, Apr 02, 2001 at 09:10:04AM -0700, Ian Lance Taylor wrote:
> Jakub Jelinek <jakub@redhat.com> writes:
> 
> > This patch does not need any modifications to port elf*.c files, but one
> > pays for this:
> > assembler has to keep local symbols in SHF_MERGE sections so that
> > relocations are against them and not against STT_SECTION symbols. But as gas
> > has -L by default turned off and ld does not have -X by default turned on
> > (ie. gas defaults to different behaviour than ld), the .L symbols will wind
> > up in the resulting executable/DSO unless -X is explicitely given or the
> > thing is stripped.
> 
> I admit that I have not looked at this problem, and it is quite likely
> that I am missing something.  However, it seems to me that you have
> all the information you need without making this change.

Do you mean without the gas/write.c change in the patch?

> The relocation to the SHF_MERGE section entry will have the SHF_MERGE
> section and the offset.  That is enough information to know which

On .rel targets, local relocations against SHF_MERGE section's .L* symbols
will be seen as relocs against STT_SECTION symbol:

        .section        .rodata.str, "ams", @progbits, 1
.LC0:
        .string "baz"
.LC1:
        .string "bar"
        .text
        .align 4
        .globl bar
        .type    bar,@function
bar:
        pushl   %ebp
        movl    $.LC0, %eax
        movl    $.LC1, %ecx
        movl    %esp, %ebp
        popl    %ebp
        ret

without the write.c change this is assembled into:
Relocation section '.rel.text' at offset 0x260 contains 2 entries:
  Offset    Info  Type            Symbol's Value  Symbol's Name
  00000002  00401 R_386_32              00000000  .rodata.str
  00000007  00401 R_386_32              00000000  .rodata.str
and the addend is in the instructions:
00000000 <bar>:
   0:   55                      push   %ebp
   1:   b8 00 00 00 00          mov    $0x0,%eax
   6:   b9 04 00 00 00          mov    $0x4,%ecx
   b:   89 e5                   mov    %esp,%ebp
   d:   5d                      pop    %ebp
   e:   c3                      ret
   f:   90                      nop

so I really don't know where can I grab this information from without
touching port headers unless the write.c change is in.

	Jakub


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