This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
RE: H8 assembler generates incorrect relocation entries.
- From: "Nitin Gupta, Noida" <niting at noida dot hcltech dot com>
- To: "Dhananjay R. Deshpande" <dhananjayd at kpit dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Tue, 3 Sep 2002 20:17:38 +0530
- Subject: RE: H8 assembler generates incorrect relocation entries.
Hi Dhananjay,
> > The references into the .text section
> > from the DWARF debug_line and debug_info section
> > are not correct when starting address is greater then
> > 2 bytes. This happens for target h8300 only.
> >
> > Execution Steps:
> > 1.) modified ldscript h8300elf.x so that the start
> > address is greater then 2 bytes.
> > $ diff -c3p
> > /home/niting/venkat/gcc_release/h8300-elf/tools/h8300-elf/lib/
> > ldscripts/h830
> > 0elf.x myh8300elf.x
> > ***
> > /home/niting/gcc_release/h8300-elf/tools/h8300-elf/lib/ldscrip
> > ts/h8300elf.x
> > Thu Aug 29 17:34:57 2002
> > --- myh8300elf.x Wed Aug 31 10:56:00 2002
> > *************** ENTRY(_start)
> > *** 9,15 ****
> > SECTIONS
> > {
> > /* Read-only sections, merged into text segment: */
> > ! . = 0x100;
> > .interp : { *(.interp) }
> > .hash : { *(.hash) }
> > .dynsym : { *(.dynsym) }
> > --- 9,15 ----
> > SECTIONS
> > {
> > /* Read-only sections, merged into text segment: */
> > ! . = 0x200200;
> > .interp : { *(.interp) }
> > .hash : { *(.hash) }
> > .dynsym : { *(.dynsym) }
> >
> > 2.) Compiled and Linked the Hello World program
> > in "C" with this ldscript for target=h8300 (default
> > options)
> > $h8300-elf-gcc -T myh8300elf.x hello.c
> >
> > 3.) Found the the text references from debug_line
> > and debug_info only contain lower 16 bits of the
> > address. Can be conformed with
> > $readelf -wil a.out
> >
> > The Problem:
> > The assembler seems to be the culprit. Because the
> > relocation entries generated for reference into text
> > section from DWARF sections are of type R_H8_DIR16
> > whereas the .text section starting address is
> > something greater then 0x200200.
>
> First let me clear that I am not familiar with all the
> details of ELF file
> format.( and DWARF ).
> The H8300 address space is limited to 16 bit ( 0xFFFF highest ).
> so all references are 16 bit. This could be the reason that
> assembler generates
> relocation entries of type R_H8_DIR16.
>
Yes, I agree. Since the address space is limited to 16 bit for
H8300 the assembler may be doing write job by generating R_H8_DIR16.
But the relocation entries of executable(.text, .init, .fini)sections
are of type R_H8_DIR32. Hence given a larger starting address linker
relocates the executable section to that address. Whereas the high order
16 bits are stripped when the addresses in the DWARF debug sections
are relocated. So the assembler should be fixed to consistently
emit relocation entries of same type for a for all virtual address
reference.
e.g. in the current implementation a debug entry referring to an
address that is relocated to 0x20020c would actually contain
0x20c.
Thanks and Regards,
Nitin.