gcc 3.3.3 and interworking

Daniel Jacobowitz drow@false.org
Fri Apr 23 02:39:00 GMT 2004


On Wed, Apr 14, 2004 at 10:18:47PM +0100, Dave Murphy wrote:
> apologies for being a complete pain, further research shows that the problem
> is something to do with the address of the text section. In the system I'm
> building the cross compiler for this is 0x08000000. Bizarrely it seems that
> any address for the text section greater than 0x01fffc0c produces the error
> (bit of an odd number really)
> 
> the patch applied to gcc-3.3.3 was from
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14166
> 
> the version of ninutils is 2.15.90 fom cvs HEAD
> 
> I've also enabled the interworking libraries in multilib.
> 
> simple testcase is :-
> 
> --- test.c ----
> 
> int main(void)
> {
> 	int x = 3;
> 	int y = 15;
> 	int z = y/x;
> 	return(0);
> }
> 
> --- compiled with ---
> 
> arm-elf-gcc -Ttext 0x2000000 -marm -mthumb-interwork test.c

First of all, don't use -TText for ELF.  It almost _never_ does what
you want it to.  You'll need an actual linker script.  Try running the
above with -Wl,-Map,foo.txt added to the command line.  This will let
you see where the linker places things.  Here's a sample - in this case
everything ended up in the right place:

Address of section .text set to 0x2000000
                0x00008074                . = (0x8000 + SIZEOF_HEADERS)
.text           0x02000000      0x114

So, something is trying to reference  __div0 from too early in the
file, it seems.  The reference naturally comes from __divsi3.  The
question is, why is it overflowing?

Ah-ha - I should have guessed.  I eliminated most explicit treatment of
R_ARM_PLT32 relocations recently, to fix this sort of bug among others;
I've had the one missing reference on my TODO list for a couple of
months, and you just hit it.  Could you test this patch to HEAD?

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

2004-04-22  Daniel Jacobowitz  <drow@mvista.com>

	* elf32-arm.h (elf32_arm_relocate_section): Remove R_ARM_PLT32
	special case.

--- elf32-arm.h.orig	2004-04-22 22:11:15.000000000 -0400
+++ elf32-arm.h	2004-04-22 22:28:37.000000000 -0400
@@ -2229,6 +2229,8 @@ elf32_arm_relocate_section (output_bfd, 
 	        case R_ARM_PC24:
 	        case R_ARM_ABS32:
 		case R_ARM_THM_PC22:
+	        case R_ARM_PLT32:
+
 	          if (info->shared
 	              && (
 			  (!info->symbolic && h->dynindx != -1)
@@ -2262,11 +2264,6 @@ elf32_arm_relocate_section (output_bfd, 
 	            relocation = 0;
 		  break;
 
-	        case R_ARM_PLT32:
-	          if (h->plt.offset != (bfd_vma)-1)
-	            relocation = 0;
-		  break;
-
 	        default:
 		  if (unresolved_reloc)
 		    _bfd_error_handler



More information about the Binutils mailing list