bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/4188] New: Different results in R_H8_PCREL8 relocations between


From: flameeyes at gmail dot com
Subject: [Bug ld/4188] New: Different results in R_H8_PCREL8 relocations between direct binary output and objcopy
Date: 15 Mar 2007 16:20:55 -0000

When building a reduced firmware image for h8300s architecture, the results of 
linking directly to a binary file with -oformat binary are wrong compared with 
the ones of linking to an elf file and then using objcopy to create a binary 
file.

I'm attaching a reduced testcase (I'm not sure how much sense the assembly 
make, I'm not so much into it, I just copied some instructions from the code 
I'm actually working it), that shows the problem.

To create the two different binary files, use these commands:

h8300-*-elf-as reduced-testcase.s -o reduced-testcase.o
h8300-*-elf-gcc -ms -nostartfiles -Wl,--oformat,binary reduced-testcase.o -o 
reduced-testcase.direct
h8300-*-elf-gcc -ms -nostartfiles reduced-testcase.o -o reduced-testcase.elf
h8300-*-elf-objcopy -O binary reduced-testcase.elf reduced-testcase.copied

The generated files have a single difference on byte 5: in the file linked 
directly in binary format is 0x03, while on the copy copied from elf it's 
0x02. The correct one is the latter, as the jump should always be aligned on 2 
bytes.

Hans-Peter Nilsson suggested the problem might be in h8_elf_howto_table, and 
this is supported by the following comment inside elf32-h8300.c:

> case R_H8_PCREL8:
>[snip]
>      /* The value is relative to the start of the instruction,
>         not the relocation offset.  Subtract 1 to account for
>         this minor issue.  */
>      value -= 1;

Likely the same problem happens with R_H8_PCREL16, as the same comment is in 
the case for that relocation type (with value decremented by two).

-- 
           Summary: Different results in R_H8_PCREL8 relocations between
                    direct binary output and objcopy
           Product: binutils
           Version: 2.17
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
        AssignedTo: unassigned at sources dot redhat dot com
        ReportedBy: flameeyes at gmail dot com
                CC: bug-binutils at gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: h8300-*-elf


http://sourceware.org/bugzilla/show_bug.cgi?id=4188

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]