Bug 1486 - DISASSEMBLER_NEEDS_RELOCS doesn't work correctly
Summary: DISASSEMBLER_NEEDS_RELOCS doesn't work correctly
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-15 19:33 UTC by H.J. Lu
Modified: 2006-01-17 17:41 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2005-10-15 19:33:34 UTC
This patch

http://sourceware.org/ml/binutils/2001-01/msg00108.html

added DISASSEMBLER_NEEDS_RELOCS based in the enabled targets at configure
time. It has several problems:

1. It isn't enabled for --enable-targets=all.
2. Objdump for i386 now has 2 different assemblers, depending on if the
enabled target defines DISASSEMBLER_NEEDS_RELOCS or not.
3. The i386 assembler works incorrectly when ARM is enabled since the assembler
is different due to DISASSEMBLER_NEEDS_RELOCS.

[hjl@gnu-13 testsuite]$ cat y.s
 .text
glob:
 jmp ext
 jmp weak
[hjl@gnu-13 testsuite]$ gcc -c -m32 y.s
[hjl@gnu-13 testsuite]$ ../../binutils/objdump -d y.o

y.o:     file format elf32-i386

Disassembly of section .text:

00000000 <glob>:
   0:   e9 fc ff ff ff          jmp    1 <glob+0x1>
   5:   e9 fc ff ff ff          jmp    6 <weak+0x6>
                                          ^^^^ It should be "glob".

which leads to "make check" failure on Linux/x86 when --enable-targets=arm-linux 
is used.

I think DISASSEMBLER_NEEDS_RELOCS should be fixed and it should be enabled
at run-time depending on targets, if needed, instead of configure time.
Comment 1 Nick Clifton 2005-10-19 17:06:21 UTC
Subject: Re:  New:  DISASSEMBLER_NEEDS_RELOCS doesn't work
 correctly

Hi H.J.

> added DISASSEMBLER_NEEDS_RELOCS based in the enabled targets at configure
> time. It has several problems:
> 
> 1. It isn't enabled for --enable-targets=all.

True, although I am not sure if this is a serious problem.


> 2. Objdump for i386 now has 2 different assemblers, depending on if the
> enabled target defines DISASSEMBLER_NEEDS_RELOCS or not.

This point has me confused.  Do you mean 2 different *assemblers* or 2 
different *disassemblers* ?


> 3. The i386 assembler works incorrectly when ARM is enabled since the assembler
> is different due to DISASSEMBLER_NEEDS_RELOCS.

Just how common is it to build such a toolchain I wonder.  Most people 
would only build a single-targeted toolchain not a multiply targeted 
toolchain like the one you mention above.


 > which leads to "make check" failure on Linux/x86 when
 > --enable-targets=arm-linux is used.

Which failure is this ?


> I think DISASSEMBLER_NEEDS_RELOCS should be fixed and it should be enabled
> at run-time depending on targets, if needed, instead of configure time.

Well this is a reasonable request and should be too hard to do.  The 
patch ought to be sure that relocs are not read in unnecessarily and 
that the absence of relocs does not prevent disassembly, but otherwise 
it should be quite straightforward.  Please feel free to submit a 
suitable patch.

Cheers
   Nick
Comment 2 H.J. Lu 2005-10-19 17:33:28 UTC
I meant "disassemblers", not "assemblers". With "-enable-targets=arm-linux",
I got

FAIL: i386 pcrel reloc
FAIL: i386 gotpc
FAIL: i386 dynamic tls

on Linux/x86. I think even with DISASSEMBLER_NEEDS_RELOCS defined, ia32
disassembler output should be the same. I suspect the bug is in implementation
of DISASSEMBLER_NEEDS_RELOCS. I can give it a try. But since I don't know the
reason behind it, I may not be able to fix it correctly.
Comment 3 Andreas Schwab 2006-01-17 17:41:09 UTC
Fixed with <http://sourceware.org/ml/binutils/2006-01/msg00134.html>.