This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
relaxing vs section merging
- From: DJ Delorie <dj at redhat dot com>
- To: binutils at sources dot redhat dot com
- Date: Mon, 26 Apr 2004 15:45:19 -0400
- Subject: relaxing vs section merging
target = mn10300-elf
host = linux
Consider linking these two files with "ld --relax":
-------------------- dj1.s
.section .text
.global _start
.type _start,@function
_start:
mov .LC1a,d1
nop
.section .rodata.str1.1,"aMS",@progbits,1
.LC1a:
.string "\n"
-------------------- dj2.s
.section .rodata.str1.1,"aMS",@progbits,1
.LC2a:
.rept 32768
.byte 'a'
.endr
.byte 0
.LC2b:
.string "abc\n"
--------------------
What I'm seeing is that the relaxation code uses the pre-merge value
of LC1a, but the relocation uses the post-merge value and thus fails
(reloc overflow). I've verified that merging happens before relaxing.
Why this happens is uncertain. Various things I've seen:
* The section for LC1a is set to *ABS* by ldlang.c, because the merge
code decided it was to be discarded.
* If I try to map LC1a through _bfd_elf_rela_local_sym, at first it
doesn't because only STT_SECTION symbols are allowed to be mapped.
* If I override the STT_SECTION check, it complains that the symbol is
outside the merged section (*ABS*, remember?)
* If I try to keep the section from being discarded (so it's not
*ABS*), it still complains as above.
So far, the only "solution" I've found is to just not relax relocs to
symbols in mergable sections, but this obviously isn't ideal. Am I
missing something obvious? Is there some fundamental bug that needs
to be fix here, and if so, where? Or should we just skip mergable
symbols?