This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Cross-GAS for HPUX on i386-Linux, once more...(some effort)


Hi,

I found several Mails in the Archive about people trying to bild a cross-gas
on i386-Linux for assembling HPUX assembler-files, but nobody seemed to be
succesfull.
The problem is always the som.c file, which due to include-dependencies
could not be compiled on Linux.
So I tried it myself and found out a possibility to compile som.c:

I mounted the source tree on an HP-UX machine and compiled the som.c with
the same command Linux was trying but added the -E option for preprocessing
only:

gcc -E \
-DHAVE_CONFIG_H \
-I. -I../../binutils-2.11.2/bfd -I. -D_GNU_SOURCE -I. \
-I../../binutils-2.11.2/bfd -I../../binutils-2.11.2/bfd/../include \
-I../../binutils-2.11.2/bfd/../intl -I../intl -Wall \
../../binutils-2.11.2/bfd/som.c > som_pre.c

With some small modification the generated som_pre.c source file can be
copiled under Linux:
Remove Line 5357 in som.c : fflush (stderr);
That doesn't hurt, but it produces unsatisfied symbols, due to diffrences in
glibc and hpux-libc handling of standard streams. There's propably another
possibility to fix this.

Anyway then I compiled som_pre.c under Linux to som.o:
gcc -c -o som.o som_pre.c
and created the som.lo file by copying and modifying another .lo file.
Then I restarted the intterupted make process and voila it succeeded.
Very happy, i tried to assemble a .s file and gas was able to assemble the
file but unfortunately the result was messy, to be more precise byte orders
were swapped, sometime only two byte swapped sometimes four bytes swap. An
explanation wasn't very difficult HPPA has diffrent Byte-oder (BIG ENDIAN)
than i386 (LOW ENDIAN). But I thougt gas could handle that. Well it doesn't.
Acually it's som.c fault, cause it's hacked just for HPPA machines.
It saves most of the resulting code in structures with shorts (16-bit) and
ints(32-bit) and writes the allocated memory of that structures directly to
file.

E.g. struct dummy {
	unsigned int a;
	unsigned short b;
}
struct dummy x;
x.a=0x44332211;
x.b=0x2211;
fwrite(output,(void*) &dummy, sizeof(struct dummy));

Result on HPPA-HPUX: hex:  44 33 22 11 22 11
       on i386-Linux hex:  11 22 33 44 11 22

O.K so far, and no my final question:
Has anybody an idea how to convert these structures easyly. I dont wan't to
convert each int or short member of all used structures to the diffrent
endian. Too lazy for that...

Bye Sven


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]