bug-gnu-utils
[Top][All Lists]
Advanced

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

bfd bug


From: Erik Shold
Subject: bfd bug
Date: Fri, 7 Sep 2001 14:52:13 -0400

I am in the process of porting our assembly automation process from aix to
linux.  We have a large regression suite of asm test cases which contain
aix target-specific syntax.  As such, the goal is to have gas set up as a
cross-assembler on linux which accepts our existing aix asm.  Toward this
end, I currently am testing with the following binutils (v2.10.1)
configuration...

configure --host=i686-pc-linux-gnu --target=powerpc-ibm-aix4.3.2.0

This configuration works fine with our aix-specific asm and produces valid
xcoff object files.  The next step in the process is to get ld to input the
xcoff object file and output an elf executable.  To accomplish this, I have
a separate native make of binutils (also v2.10.1) configured as...

configure --host=powerpc-linux

The native loader accepts the xcoff object files output by the
cross-assembler and generates an elf executable.  The xcoff->elf transition
(presumably via bfd routines) is problematic, however.  In examining the
contents of the elf executable, it is apparent that branch targets are
being improperly resolved.  It appears that the reason for this is that ld
mistakes the program text section as a data section and calculates
addresses as offsets of the -Tdata ld parameter, rather than -Ttext.  I'm
invoking ld as...

ld -Ttext 0xfffff800 -Tdata 0xffffff00 -e 0xfffff800

So if, for example, I do a branch to the beginning of main, the branch
target is encoded into the instruction as 0xffffff00, rather than
0xfffff800.

In addition to what is apparent from the branch addresses as shown above,
the elf executable indicates that it has mistaken the text section for a
data section in that its section header flags (scnhdr->sh_flags) include
SHF_WRITE rather than SHF_EXECINSTR. Also, if I look at the section header
name string table, sections labeled as ".text" and ".data" contain zero
bytes of data.  The respective sections where the data actually does reside
have been labeled as ".pr" and ".rw" (evidently based on ".csect
main_prog[pr]",  ".csect data_sec[rw]" flavor labels used to declare them).
To clarify, both the ".pr" and ".rw" sections which ld puts in the elf
executable are flagged as SHF_WRITE (neither with SHF_EXECINST),
identifying both as data sections.

I attempted to bypass the loader section misplacement issue by using the
objcopy utility to convert the xcoff object file output from the
cross-assembler to an elf object file, which I could then pass to ld,
without it needing to do any file conversion (though presumably objcopy
would accomplish the conversion via the same bfd routines invoked by the
loader - but why not try, right?).  An "objdump -i" under the
cross-configuration (1st above) indicates, as expected, that there is no
valid elf target supported for objcopy.  For the native configuration,
objdump lists elf32-powerpc as a valid target (as well as aixcoff-rs6000).
However, when I attempt to convert the xcoff file generated by gas to elf
as...

objcopy -O elf32-powerpc some_xcoff_file.o

I get the following output...

objcopy: Warning: Output file cannot represent architecture rs6000:6000
BFD: statTxHr: unsupported relocation type R_BA
objcopy: statTxHr: Bad value

(I assume that "statTxHr" is the temporary file that the conversion is
written to, which then overwrites the original some_xcoff_file.o?)

As an additional note of interest, if I run the elf executable (containing
the section problems mentioned above) through objcopy (native version), I
get the following...

BFD: Error: First section in segment (.pr) starts at 0xffffff00
BFD:        whereas segment starts at 0xfffff800
objcopy: sto0gC5c: No such file or directory

So objcopy recognizes the error condition created by ld misplacing the text
section.

Any assistance/fixes/recommendations would be greatly appreciated.

Regards,

Erik A. Shold
IBM - PowerPC Microelectronics




reply via email to

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