public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Cross-Compiling Help
@ 2002-12-19  8:51 Kerr Shannon-SKERR1
  0 siblings, 0 replies; 7+ messages in thread
From: Kerr Shannon-SKERR1 @ 2002-12-19  8:51 UTC (permalink / raw)
  To: 'gcc-help@gcc.gnu.org'

Hello,

Does anyone know if we can expect a cross-compiled object to be equivalent
to a natively compiled object when the cross-compiler was configured with
GCC-3.2 using the headers and libraries from the native machines GCC-3.2?
The host for the cross-compiler is a SunOS 5.6 machine.  The target (native)
is an i686 Red Hat 7.3 Linux box.

The configuration, source, headers and libraries match, but the final
stripped binaries are about 500 bytes different.  We used the -static on the
natively compiled object so the objects should have compared the same, but
they are slightly different.

Should we expect to get objects that are binarily equivalent?  Is it
possible?  We've heard it's been done with some off the shelf compilers, but
we've never tried with GCC.

We need to prove that cross-compiling is just as good as compiling on the
native machine so we don't have to purchase a bunch of new machines to build
on and support.  We have a nice SunOS build pool of machines and want to
cross-compile there for our target machine.

Any documents or studies done in this area that anyone knows of would be
great.  Any help in getting our compilers to produce equivalent binaries
would be great also.

Thanks,

Mr. Shannon Kerr

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: Cross-Compiling Help
@ 2002-12-20  7:44 Ruppert
  0 siblings, 0 replies; 7+ messages in thread
From: Ruppert @ 2002-12-20  7:44 UTC (permalink / raw)
  To: gcc-help; +Cc: shannon.kerr


> 
> Well, I was able to extract the .text section thanks to the suggestion from
> Ruppert (thanks).  The comparison wasn't pretty.  Actually, I am trying just
> a simple "hello_world" type program and the diff of the objdump didn't look
> good at all.  Ruppert, can you or anyone else tell me how to get the map
> file using gcc?  I'm not familiar with the GCC toolset and I would like to
> see the difference between the map files for the two objects.

Add 

      -Wl,-Map,foo.map
      
(no blanks in between) to your link command line (see the docs for GNU ld, 
also part of binutils).


> 
> Also, we compared the assembly code generated by gcc (gcc -S) and the code
> generated by the cross-compiler gcc and the native gcc were identical!  We
> then executed gcc -c for each and compared the unlinked binaries (assembled
> code) and the two binaries were again an exact match.  But when we go to
> link the objects (gcc -o foo.o foo.c), that's when everything changes.

This indicates that the assembler works as expected.

> 
> The stripped binaries match in size, but using cmp to compare the two, they
> do not match.  I compared the objdumps and they do match up to a point and
> then the rest of the file does not match (only about 1/10th match and then
> the assembly instructions are very different after that).
>

The linker combines your objects with "startup code" and libraries (use 
-v on the link command line to see the complete invocation of ld). Maybe
the difference is from one of these components. You should be able to
deduce this from the link map: add the offset of the first difference
(from cmp) to the .text start address (in the mapfile) and locate the
corresponding module in the mapfile. If this is within startup code (modules
with names like crt0.o, crtbegin.o etc.) or within library code then your
linkers pick up different startup code modules or libraries.

Regards
D.Ruppert

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: Cross-Compiling Help
@ 2002-12-19 20:09 Kerr Shannon-SKERR1
  0 siblings, 0 replies; 7+ messages in thread
From: Kerr Shannon-SKERR1 @ 2002-12-19 20:09 UTC (permalink / raw)
  To: 'Andrea 'fwyzard' Bocci'; +Cc: gcc-help, 'Ruppert'

We used the same binutils 2-13.1 release for both.

-Shannon

-----Original Message-----

>The problem, then, is not in GCC itself, but in the binutils.
>I'm terribly ignorant on this issue  - the only suggestion I can come out 
>with is to ask for help and cleverer suggestions on the binutils mailing 
>list :-)

>At 12.08 19/12/2002 -0600, Kerr Shannon-SKERR1 wrote:
>>Well, I was able to extract the .text section thanks to the suggestion
from
>>Ruppert (thanks).  The comparison wasn't pretty.  Actually, I am trying
just
>>a simple "hello_world" type program and the diff of the objdump didn't
look
>>good at all.  Ruppert, can you or anyone else tell me how to get the map
>>file using gcc?  I'm not familiar with the GCC toolset and I would like to
>>see the difference between the map files for the two objects.
>>
>>Also, we compared the assembly code generated by gcc (gcc -S) and the code
>>generated by the cross-compiler gcc and the native gcc were identical!  We
>>then executed gcc -c for each and compared the unlinked binaries
(assembled
>>code) and the two binaries were again an exact match.  But when we go to
>>link the objects (gcc -o foo.o foo.c), that's when everything changes.
>>
>>The stripped binaries match in size, but using cmp to compare the two,
they
>>do not match.  I compared the objdumps and they do match up to a point and
>>then the rest of the file does not match (only about 1/10th match and then
>>the assembly instructions are very different after that).
>>
>>I really appreciate everyone's help in this.
>>
>>Thanks,
>>
>>Mr. Shannon Kerr

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: Cross-Compiling Help
       [not found] <49B18DE31018D5118FBA009027B0FE990CE1DAA4@IL27EXM07.cig.mot .com>
@ 2002-12-19 14:10 ` Andrea 'fwyzard' Bocci
  0 siblings, 0 replies; 7+ messages in thread
From: Andrea 'fwyzard' Bocci @ 2002-12-19 14:10 UTC (permalink / raw)
  To: Kerr Shannon-SKERR1; +Cc: 'gcc-help@gcc.gnu.org', 'Ruppert'

The problem, then, is not in GCC itself, but in the binutils.
I'm terribly ignorant on this issue  - the only suggestion I can come out 
with is to ask for help and cleverer suggestions on the binutils mailing 
list :-)

At 12.08 19/12/2002 -0600, Kerr Shannon-SKERR1 wrote:
>Well, I was able to extract the .text section thanks to the suggestion from
>Ruppert (thanks).  The comparison wasn't pretty.  Actually, I am trying just
>a simple "hello_world" type program and the diff of the objdump didn't look
>good at all.  Ruppert, can you or anyone else tell me how to get the map
>file using gcc?  I'm not familiar with the GCC toolset and I would like to
>see the difference between the map files for the two objects.
>
>Also, we compared the assembly code generated by gcc (gcc -S) and the code
>generated by the cross-compiler gcc and the native gcc were identical!  We
>then executed gcc -c for each and compared the unlinked binaries (assembled
>code) and the two binaries were again an exact match.  But when we go to
>link the objects (gcc -o foo.o foo.c), that's when everything changes.
>
>The stripped binaries match in size, but using cmp to compare the two, they
>do not match.  I compared the objdumps and they do match up to a point and
>then the rest of the file does not match (only about 1/10th match and then
>the assembly instructions are very different after that).
>
>I really appreciate everyone's help in this.
>
>Thanks,
>
>Mr. Shannon Kerr


^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: Cross-Compiling Help
@ 2002-12-19 13:06 Kerr Shannon-SKERR1
  0 siblings, 0 replies; 7+ messages in thread
From: Kerr Shannon-SKERR1 @ 2002-12-19 13:06 UTC (permalink / raw)
  To: 'gcc-help@gcc.gnu.org'; +Cc: 'Ruppert'

Well, I was able to extract the .text section thanks to the suggestion from
Ruppert (thanks).  The comparison wasn't pretty.  Actually, I am trying just
a simple "hello_world" type program and the diff of the objdump didn't look
good at all.  Ruppert, can you or anyone else tell me how to get the map
file using gcc?  I'm not familiar with the GCC toolset and I would like to
see the difference between the map files for the two objects.

Also, we compared the assembly code generated by gcc (gcc -S) and the code
generated by the cross-compiler gcc and the native gcc were identical!  We
then executed gcc -c for each and compared the unlinked binaries (assembled
code) and the two binaries were again an exact match.  But when we go to
link the objects (gcc -o foo.o foo.c), that's when everything changes.

The stripped binaries match in size, but using cmp to compare the two, they
do not match.  I compared the objdumps and they do match up to a point and
then the rest of the file does not match (only about 1/10th match and then
the assembly instructions are very different after that).

I really appreciate everyone's help in this.

Thanks,

Mr. Shannon Kerr

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: Cross-Compiling Help
@ 2002-12-19 10:51 Ruppert
  0 siblings, 0 replies; 7+ messages in thread
From: Ruppert @ 2002-12-19 10:51 UTC (permalink / raw)
  To: gcc-help; +Cc: shannon.kerr


Hi,

> 
> btw, We have used the "size" utility and it shows that our two binaries have
> the same segment/section sizes.  That only proves the sizes are the same and
> not the segment/section contents.  If we can show that the segment/section
> contents are the same, does this prove that the binaries are effectively the
> same?  Is there a way to compare section/segment content?


I once used the objcopy utility for something similar (it is part
of binutils). I could extract the code section (.text) into a
separate file (using objcopy -j .text ...) and then I simply 
used cmp to do the binary comparison. cmp prints the offset of
the differences (if any), and these can be matched against a link mapfile
to locate the objects which cause the difference. With this 
information in turn I used objdump on the objects to locate the
differences in machine code.

This, of course, is only feasible for a small number of differences.

---------------------------------------------------------------------
Regards
D.Ruppert
RTS GmbH

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: Cross-Compiling Help
@ 2002-12-19  9:29 Kerr Shannon-SKERR1
  0 siblings, 0 replies; 7+ messages in thread
From: Kerr Shannon-SKERR1 @ 2002-12-19  9:29 UTC (permalink / raw)
  To: 'gcc-help@gcc.gnu.org'

btw, We have used the "size" utility and it shows that our two binaries have
the same segment/section sizes.  That only proves the sizes are the same and
not the segment/section contents.  If we can show that the segment/section
contents are the same, does this prove that the binaries are effectively the
same?  Is there a way to compare section/segment content?

Thanks,

Mr. Shannon Kerr

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-12-20  7:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-19  8:51 Cross-Compiling Help Kerr Shannon-SKERR1
2002-12-19  9:29 Kerr Shannon-SKERR1
2002-12-19 10:51 Ruppert
2002-12-19 13:06 Kerr Shannon-SKERR1
     [not found] <49B18DE31018D5118FBA009027B0FE990CE1DAA4@IL27EXM07.cig.mot .com>
2002-12-19 14:10 ` Andrea 'fwyzard' Bocci
2002-12-19 20:09 Kerr Shannon-SKERR1
2002-12-20  7:44 Ruppert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).