Skip to contentSkip to conversation

Linker problems

parisc-linux Philipp Rumpf 1 participant 3 messages Dec 5, 1999 – Dec 6, 1999 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

Okay, it looks like HP/UX ld is behaving funny for some things in the 2.3 kernel. Most notable fs/buffer.c, buffer_init:

Assembly source piped to gas:

	addil LR'hash_table-$global$,%r27
	copy %r1,%r12
	addil LR'bh_hash_shift-$global$,%r27
	copy %r1,%r10
	addil LR'zonelists-$global$,%r27
	comib,>>= 1,%r3,L$4451

Generated object file (objdump -d --reloc fs/buffer.o):

      84:   2b 60 00 00     addil 0,dp,%r1
                        84: R_DP_RELATIVE       hash_table
      88:   08 01 02 4c     copy r1,r12
      8c:   2b 60 00 00     addil 0,dp,%r1
                        8c: R_DP_RELATIVE       bh_hash_shift
      90:   08 01 02 4a     copy r1,r10
      94:   2b 60 00 00     addil 0,dp,%r1
                        94: R_DP_RELATIVE       zonelists
      98:   8c 62 80 30     cmpib,>>= 1,r3,b8 <buffer_init+0xb8>

vmlinux (objdump -d --reloc vmlinux):

c0063884:       2b 70 30 00     addil 21800,dp,%r1
c0063888:       08 01 02 4c     copy r1,r12
c006388c:       28 0f 70 00     addil 5f800,r0,%r1
c0063890:       08 01 02 4a     copy r1,r10
c0063894:       2b 77 50 00     addil 6e800,dp,%r1
c0063898:       8c 62 80 30     cmpib,>>= 1,r3,c00638b8 <buffer_init+0xb8>

Note that

	addil LR'bh_hash_shift-$global$,%r27
	copy %r1,%r10

ultimately becomes addil 0x5f800, _r0_, %r1, which doesn't make sense (and causes a DPF lateron).

I haven't found anything obvious that could explain it in the linker source, but I haven't looked too closely at it.

Sorting this out is pretty much required to get 2.3 up (otoh, we're getting to buffer_init which is relatively far (into the parts that have changed heavily)).

Any ideas ?

Philipp Rumpf

#1 lore raw

I just verified that the problem exists with the linker as compiled from the GPL'd source (which required some minor modifications to the CVS ld).

Philipp Rumpf

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 2 lines

I just verified that the problem exists with the linker as compiled from the GPL'd source (which required some minor modifications to the CVS ld).

Here's the diff against fixups.c (including stuff I added to ignore R_SHORT_PCREL_MODE which we get for some reason (that might be a gas funny)).

fixups.c +11 -2
diff -ur linker-cvs/fixups.c linker/fixups.c
@@ -360,6 +360,10 @@
     /*  PA2.0 instructions */
     {   R_SHORT_PCREL_MODE,  1,   1,      NONE,   NONE,  NONE   },
     {   R_LONG_PCREL_MODE,   1,   1,      NONE,   NONE,  NONE   },
+#else
+	/* we seem to get R_SHORT_PCREL_MODE -- which I guess is the "do the
+	 * PA1.1 thing" one which would mean we can just ignore it.  prumpf */
+    {   R_SHORT_PCREL_MODE,  1,   1,      NONE,   NONE,  NONE   },
 #endif /* ifdef PA_2_0 */
     {   R_ABS_CALL        , 10,   2,      AR_D,   U_8,   NONE   },
     {   0                 ,  2,   3,      AR_9,   U_8,   NONE   },
@@ -1339,6 +1343,11 @@
 		GET_NO_ARGS;
 		is_pcrel_short = FALSE;
 		break;
+#else
+	    case R_SHORT_PCREL_MODE:
+		GET_NO_ARGS;
+		/* we just ignore R_SHORT_PCREL_MODE on PA1.1.  prumpf */
+		break;
 #endif /* ifdef PA_2_0 */
 
             /* zero length, clear overrides */
@@ -4342,9 +4351,9 @@
 
     switch (fix_info->type) {
 #ifdef PA_2_0
-	case R_SHORT_PCREL_MODE:
 	case  R_LONG_PCREL_MODE:
 #endif /* ifdef PA_2_0 */
+	case R_SHORT_PCREL_MODE:
         case R_BEGIN_BRTAB:
         case R_END_BRTAB:
         case R_FSEL:
@@ -5388,7 +5397,7 @@
 	        value = symbol_value(arg0);
 		if (GET_OP(instruction) == 0x0a) {          /* if an ADDIL */
 		    /* set to addil L'sym, r0 */
-		    instruction = (instruction & REG_MASK);
+		    instruction = (instruction & REG_MASK) | R27_MASK;
 		}
 		/* else ldw/stw is set to use r1 already */
 #ifdef TSD /* TSD */

The important part is

- instruction = (instruction & REG_MASK);
+ instruction = (instruction & REG_MASK) | R27_MASK;

. I don't really know what my changes do, just the kernel links correctly with them and doesn't without.

Anyway, kudos to the folks who convinced HP to GPL the linker in the first place. Otherwise, we'd be pretty stuck by now.

Philipp Rumpf