* Why does ELF/alpha put none-text relocations in .rela.text?
@ 2001-08-20 11:44 H . J . Lu
2001-08-20 15:03 ` Richard Henderson
2001-08-20 15:06 ` H . J . Lu
0 siblings, 2 replies; 7+ messages in thread
From: H . J . Lu @ 2001-08-20 11:44 UTC (permalink / raw)
To: rth; +Cc: binutils
When you do
# gcc -c foo.c
on ELF/alpha, as will put relocations for ".debug_line" in
.rela.text. When you do
# strip --strip-debug foo.o
# readelf -r foo.o
you will get
00000000 200569c000000006 R_ALPHA_GPDISP bad symbol index: 200569c0
How should we fix it?
H.J.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Why does ELF/alpha put none-text relocations in .rela.text?
2001-08-20 11:44 Why does ELF/alpha put none-text relocations in .rela.text? H . J . Lu
@ 2001-08-20 15:03 ` Richard Henderson
2001-08-20 15:46 ` H . J . Lu
2001-08-20 16:05 ` H . J . Lu
2001-08-20 15:06 ` H . J . Lu
1 sibling, 2 replies; 7+ messages in thread
From: Richard Henderson @ 2001-08-20 15:03 UTC (permalink / raw)
To: H . J . Lu; +Cc: binutils
On Mon, Aug 20, 2001 at 11:44:19AM -0700, H . J . Lu wrote:
> 00000000 200569c000000006 R_ALPHA_GPDISP bad symbol index: 200569c0
>
> How should we fix it?
The symbol for GPDISP is completely irrelevant. Only the offset
is meaningful. Use the current section symbol rather than a
random section symbol.
r~
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Why does ELF/alpha put none-text relocations in .rela.text?
2001-08-20 11:44 Why does ELF/alpha put none-text relocations in .rela.text? H . J . Lu
2001-08-20 15:03 ` Richard Henderson
@ 2001-08-20 15:06 ` H . J . Lu
1 sibling, 0 replies; 7+ messages in thread
From: H . J . Lu @ 2001-08-20 15:06 UTC (permalink / raw)
To: rth; +Cc: binutils
On Mon, Aug 20, 2001 at 11:44:19AM -0700, H . J . Lu wrote:
> When you do
>
> # gcc -c foo.c
>
> on ELF/alpha, as will put relocations for ".debug_line" in
> .rela.text. When you do
>
> # strip --strip-debug foo.o
> # readelf -r foo.o
>
> you will get
>
> 00000000 200569c000000006 R_ALPHA_GPDISP bad symbol index: 200569c0
>
> How should we fix it?
I think the real problem is ELF/alpha abuses ELF64_R_SYM for the GPDISP
relocations where the symbol index is not really an index into the
symbol table. But the generic part of the ELF linker in BFD assumes
ELF64_R_SYM is a real symbol index. I will see what I can do.
H.J.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Why does ELF/alpha put none-text relocations in .rela.text?
2001-08-20 15:03 ` Richard Henderson
@ 2001-08-20 15:46 ` H . J . Lu
2001-08-20 16:05 ` H . J . Lu
1 sibling, 0 replies; 7+ messages in thread
From: H . J . Lu @ 2001-08-20 15:46 UTC (permalink / raw)
To: Richard Henderson; +Cc: binutils
On Mon, Aug 20, 2001 at 03:03:28PM -0700, Richard Henderson wrote:
> On Mon, Aug 20, 2001 at 11:44:19AM -0700, H . J . Lu wrote:
> > 00000000 200569c000000006 R_ALPHA_GPDISP bad symbol index: 200569c0
> >
> > How should we fix it?
>
> The symbol for GPDISP is completely irrelevant. Only the offset
> is meaningful. Use the current section symbol rather than a
> random section symbol.
But it is a bad idea to use the debug section symbol since it may
be removed.
H.J.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Why does ELF/alpha put none-text relocations in .rela.text?
2001-08-20 15:03 ` Richard Henderson
2001-08-20 15:46 ` H . J . Lu
@ 2001-08-20 16:05 ` H . J . Lu
2001-08-20 16:47 ` PATCH: Avoid setting the bogus section symbol index H . J . Lu
2001-08-20 17:11 ` Why does ELF/alpha put none-text relocations in .rela.text? Richard Henderson
1 sibling, 2 replies; 7+ messages in thread
From: H . J . Lu @ 2001-08-20 16:05 UTC (permalink / raw)
To: Richard Henderson; +Cc: binutils, amodra
On Mon, Aug 20, 2001 at 03:03:28PM -0700, Richard Henderson wrote:
> On Mon, Aug 20, 2001 at 11:44:19AM -0700, H . J . Lu wrote:
> > 00000000 200569c000000006 R_ALPHA_GPDISP bad symbol index: 200569c0
> >
> > How should we fix it?
>
> The symbol for GPDISP is completely irrelevant. Only the offset
> is meaningful. Use the current section symbol rather than a
> random section symbol.
>
But we are using a random section symbol since we never reset now_seg.
This patch seems to work for me. Alan, do you have any comments?
Thanks.
H.J.
----
2001-08-20 H.J. Lu <hjl@gnu.org>
* write.c (write_relocs): Reset the current section.
Index: write.c
===================================================================
RCS file: /work/cvs/gnu/binutils/gas/write.c,v
retrieving revision 1.26
diff -u -p -r1.26 write.c
--- write.c 2001/08/03 15:55:50 1.26
+++ write.c 2001/08/20 23:00:50
@@ -958,6 +958,8 @@ write_relocs (abfd, sec, xxx)
if (seginfo == NULL)
return;
+ subseg_change (sec, 0);
+
fixup_segment (seginfo->fix_root, sec);
n = 0;
^ permalink raw reply [flat|nested] 7+ messages in thread
* PATCH: Avoid setting the bogus section symbol index.
2001-08-20 16:05 ` H . J . Lu
@ 2001-08-20 16:47 ` H . J . Lu
2001-08-20 17:11 ` Why does ELF/alpha put none-text relocations in .rela.text? Richard Henderson
1 sibling, 0 replies; 7+ messages in thread
From: H . J . Lu @ 2001-08-20 16:47 UTC (permalink / raw)
To: Richard Henderson; +Cc: binutils, amodra
On Mon, Aug 20, 2001 at 04:05:15PM -0700, H . J . Lu wrote:
> On Mon, Aug 20, 2001 at 03:03:28PM -0700, Richard Henderson wrote:
> > On Mon, Aug 20, 2001 at 11:44:19AM -0700, H . J . Lu wrote:
> > > 00000000 200569c000000006 R_ALPHA_GPDISP bad symbol index: 200569c0
> > >
> > > How should we fix it?
> >
> > The symbol for GPDISP is completely irrelevant. Only the offset
> > is meaningful. Use the current section symbol rather than a
> > random section symbol.
> >
>
Here is a patch to avoid setting the bogus section symbol index. Now,
I am getting:
/export/build/gnu/binutils/build-alpha-linux/binutils/strip-new --strip-debug foo.o -o strip.o
BFD: strip.o: symbol `.debug_line' required but not present
I will check it in shortly if there is no objection.
H.J.
----
2001-08-20 H.J. Lu <hjl@gnu.org>
* elf-bfd.h (elf_obj_tdata): Add num_section_syms.
(elf_num_section_syms): New for num_section_syms.
* elf.c (elf_map_symbols): Set num_section_syms.
(_bfd_elf_symbol_from_bfd_symbol): Check num_section_syms for
the section symbol index.
Index: elf-bfd.h
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/elf-bfd.h,v
retrieving revision 1.15
diff -u -p -r1.15 elf-bfd.h
--- elf-bfd.h 2001/08/17 17:56:19 1.15
+++ elf-bfd.h 2001/08/20 23:42:08
@@ -821,6 +821,7 @@ struct elf_obj_tdata
struct bfd_strtab_hash *strtab_ptr;
int num_locals;
int num_globals;
+ int num_section_syms;
asymbol **section_syms; /* STT_SECTION symbols for each section */
Elf_Internal_Shdr symtab_hdr;
Elf_Internal_Shdr shstrtab_hdr;
@@ -962,6 +963,7 @@ struct elf_obj_tdata
#define elf_num_locals(bfd) (elf_tdata(bfd) -> num_locals)
#define elf_num_globals(bfd) (elf_tdata(bfd) -> num_globals)
#define elf_section_syms(bfd) (elf_tdata(bfd) -> section_syms)
+#define elf_num_section_syms(bfd) (elf_tdata(bfd) -> num_section_syms)
#define core_prpsinfo(bfd) (elf_tdata(bfd) -> prpsinfo)
#define core_prstatus(bfd) (elf_tdata(bfd) -> prstatus)
#define elf_gp(bfd) (elf_tdata(bfd) -> gp)
Index: elf.c
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/elf.c,v
retrieving revision 1.60
diff -u -p -r1.60 elf.c
--- elf.c 2001/08/17 17:56:19 1.60
+++ elf.c 2001/08/20 23:42:08
@@ -2092,6 +2092,7 @@ elf_map_symbols (abfd)
if (sect_syms == NULL)
return false;
elf_section_syms (abfd) = sect_syms;
+ elf_num_section_syms (abfd) = max_index;
for (idx = 0; idx < symcount; idx++)
{
@@ -3652,7 +3653,8 @@ _bfd_elf_symbol_from_bfd_symbol (abfd, a
indx = asym_ptr->section->output_section->index;
else
indx = asym_ptr->section->index;
- if (elf_section_syms (abfd)[indx])
+ if (indx < elf_num_section_syms (abfd)
+ && elf_section_syms (abfd)[indx])
asym_ptr->udata.i = elf_section_syms (abfd)[indx]->udata.i;
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Why does ELF/alpha put none-text relocations in .rela.text?
2001-08-20 16:05 ` H . J . Lu
2001-08-20 16:47 ` PATCH: Avoid setting the bogus section symbol index H . J . Lu
@ 2001-08-20 17:11 ` Richard Henderson
1 sibling, 0 replies; 7+ messages in thread
From: Richard Henderson @ 2001-08-20 17:11 UTC (permalink / raw)
To: H . J . Lu; +Cc: binutils, amodra
On Mon, Aug 20, 2001 at 04:05:15PM -0700, H . J . Lu wrote:
> But we are using a random section symbol since we never reset now_seg.
Um, no, that's just as broken.
r~
* config/tc-alpha.h (MD_APPLY_FIX3): Define.
* config/tc-alpha.c (md_apply_fix3): Rename from md_apply_fix;
use seg parameter instead of now_seg.
Index: tc-alpha.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-alpha.c,v
retrieving revision 1.24
diff -c -p -d -u -r1.24 tc-alpha.c
--- tc-alpha.c 2001/06/24 16:43:31 1.24
+++ tc-alpha.c 2001/08/21 00:08:15
@@ -1159,9 +1159,10 @@ md_pcrel_from (fixP)
GPDISP. */
int
-md_apply_fix (fixP, valueP)
+md_apply_fix3 (fixP, valueP, seg)
fixS *fixP;
valueT *valueP;
+ segT seg;
{
char * const fixpos = fixP->fx_frag->fr_literal + fixP->fx_where;
valueT value = *valueP;
@@ -1196,7 +1197,7 @@ md_apply_fix (fixP, valueP)
#endif
do_reloc_gp:
- fixP->fx_addsy = section_symbol (now_seg);
+ fixP->fx_addsy = section_symbol (seg);
md_number_to_chars (fixpos, value, 2);
break;
Index: tc-alpha.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-alpha.h,v
retrieving revision 1.7
diff -c -p -d -u -r1.7 tc-alpha.h
--- tc-alpha.h 2001/07/23 14:02:12 1.7
+++ tc-alpha.h 2001/08/21 00:08:15
@@ -49,6 +49,7 @@ extern valueT alpha_gp_value;
#define TC_FORCE_RELOCATION(FIXP) alpha_force_relocation (FIXP)
#define tc_fix_adjustable(FIXP) alpha_fix_adjustable (FIXP)
#define RELOC_REQUIRES_SYMBOL
+#define MD_APPLY_FIX3
/* This expression evaluates to false if the relocation is for a local
object for which we still want to do the relocation at runtime.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2001-08-20 17:11 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-20 11:44 Why does ELF/alpha put none-text relocations in .rela.text? H . J . Lu
2001-08-20 15:03 ` Richard Henderson
2001-08-20 15:46 ` H . J . Lu
2001-08-20 16:05 ` H . J . Lu
2001-08-20 16:47 ` PATCH: Avoid setting the bogus section symbol index H . J . Lu
2001-08-20 17:11 ` Why does ELF/alpha put none-text relocations in .rela.text? Richard Henderson
2001-08-20 15:06 ` H . J . Lu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).