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]

Re: File truncation in objcopy for hppa2.0w-hp-hpux11.11 in binutils-2.13.1


sdowning@fame.com (Stuart F. Downing) writes:

> invocation:
> objcopy --keep-global-symbols=list_of_globals foo.o
> 
> I debugged this in gdb and see that the problem is the foo.o contains a
> R_SHORT_PCREL_MODE relocation.  som.c has code that is conditionally
> included ...
> #ifndef NO_PCREL_MODES
> 
> which is defined in som.c ...
> 
> #ifndef R_SHORT_PCREL_MODE
> 
> which is defined in /usr/include/reloc.h ...
> 
> #ifdef PA_2_0
> 
> I don't think that PA_2_0 was defined when som.c was compiled (it's
> not in config.h)...
> 
> <BUILDLOG>
> /bin/sh ./libtool --mode=compile gcc -DHAVE_CONFIG_H -I. -I/opt/src/binutils-2.1
> 3.1/bfd -I. -D_GNU_SOURCE -DHOST_HPPAHPUX -DHPUX_CORE   -I. -I/opt/src/binutils-
> 2.13.1/bfd -I/opt/src/binutils-2.13.1/bfd/../include  -I/opt/src/binutils-2.13.1
> /bfd/../intl -I../intl   -W -Wall -Wstrict-prototypes -Wmissing-prototypes -g -O
> 2 -c /opt/src/binutils-2.13.1/bfd/som.c
> gcc -DHAVE_CONFIG_H -I. -I/opt/src/binutils-2.13.1/bfd -I. -D_GNU_SOURCE -DHOST_
> HPPAHPUX -DHPUX_CORE -I. -I/opt/src/binutils-2.13.1/bfd -I/opt/src/binutils-2.13
> .1/bfd/../include -I/opt/src/binutils-2.13.1/bfd/../intl -I../intl -W -Wall -Wst
> rict-prototypes -Wmissing-prototypes -g -O2 -c /opt/src/binutils-2.13.1/bfd/som.
> c -o som.o
> /opt/src/binutils-2.13.1/bfd/som.c: In function `hppa_som_gen_reloc_type':
> /opt/src/binutils-2.13.1/bfd/som.c:1567: warning: enumeration value `e_ltpsel' n
> ot handled in switch
> /opt/src/binutils-2.13.1/bfd/som.c:1567: warning: enumeration value `e_rtpsel' n
> ot handled in switch
> /opt/src/binutils-2.13.1/bfd/som.c: In function `som_object_setup':
> /opt/src/binutils-2.13.1/bfd/som.c:1801: warning: comparison between signed and
> unsigned
> /opt/src/binutils-2.13.1/bfd/som.c:1801: warning: comparison between signed and
> unsigned
> /opt/src/binutils-2.13.1/bfd/som.c: In function `setup_sections':
> /opt/src/binutils-2.13.1/bfd/som.c:1946: warning: comparison between signed and
> unsigned
> /opt/src/binutils-2.13.1/bfd/som.c: In function `bfd_section_from_som_symbol':
> /opt/src/binutils-2.13.1/bfd/som.c:4279: warning: comparison between signed and
> unsigned
> </BUILDLOG>
> 
> The file trunction error occurs here...
> 
>               switch (bfd_reloc->howto->type)
>                 {
> ...
> #ifndef NO_PCREL_MODES
>                 case R_SHORT_PCREL_MODE:
>                 case R_LONG_PCREL_MODE:
> #endif
>                   reloc_offset = bfd_reloc->address;
>                   break;
> 
>                 default:
>                   reloc_offset = bfd_reloc->address + 4;
>                   break;
>                 }
> 
> because NO_PCREL_MODES is defined, so the default path is taken, then
> in the next loop iteration, when it calculates skip
> 
>               skip = bfd_reloc->address - reloc_offset;
> 
> This is an unsigned computation where bfd_reloc->address <
> reloc_offset which results in a very large number.
> 
> 
> I think the solution is for PA_2_0 to be defined when som.c is
> compiled, but I'm not sure what is the "right" way to accomplish this.
> 
> Should configure detect this situation and define PA_2_0 in config.h?
> 
> -- 
> Stuart Downing

I solved this with the attached patch.  Not sure if configure.host is
the right place for this, but it worked for me...
-- 
Stuart Downing

Index: src/bfd/ChangeLog
===================================================================
RCS file: /cvs/src/src/bfd/ChangeLog,v
retrieving revision 1.1598.2.41
diff -u -r1.1598.2.41 ChangeLog
--- src/bfd/ChangeLog	7 Nov 2002 22:30:54 -0000	1.1598.2.41
+++ src/bfd/ChangeLog	20 May 2003 19:24:17 -0000
@@ -1,3 +1,7 @@
+2003-05-20  Stuart F. Downing  <sdowning@fame.com>
+
+	* configure.host: Add hppa2*-*-hpux* with -DPA_2_0
+
 2002-11-07  Daniel Jacobowitz  <drow@mvista.com>
 
 	* configure.in: Bump version and set is_release.
Index: src/bfd/configure.host
===================================================================
RCS file: /cvs/src/src/bfd/configure.host,v
retrieving revision 1.9
diff -u -r1.9 configure.host
--- src/bfd/configure.host	22 Jan 2002 00:47:21 -0000	1.9
+++ src/bfd/configure.host	20 May 2003 19:24:17 -0000
@@ -23,6 +23,7 @@
 
 hppa*64*-*-hpux*)	HDEFINES=-DHOST_HPPAHPUX;
 			host64=true; HOST_64BIT_TYPE=long ;;
+hppa2*-*-hpux*)		HDEFINES="-DHOST_HPPAHPUX -DPA_2_0" ;;
 hppa*-*-hpux*)		HDEFINES=-DHOST_HPPAHPUX ;;
 hppa*-*-hiux*)		HDEFINES=-DHOST_HPPAHPUX ;;
 hppa*64*-*-linux*)	host64=true; HOST_64BIT_TYPE=long ;;

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