[gnu.gcc.bug] problem with gcc 1.32 and the Ultrix LK linker

nesheim@THINK.COM (01/07/89)

For the following code fragment, 
extern int *_CMI_scratch_ram;

test(field1)
    int field1;
{
    int field1_loc_1;
    {
	field1_loc_1 = 
	    _CMI_scratch_ram[ (((short*)&(field1))[1] <<2) ] 
		+                 (((short*)&(field1))[0] ) ;
    }
    return (field1_loc_1);
}

gcc version 1.32 generates the
following assembly code:

.text
            .align 1
    .globl _test
    _test:
            .word 0xc0
            subl2 $4,sp
            cvtwl 6(ap),r6
            moval 0[r6],r6    <--- Flagged as illegal by the LK linker
            cvtwl 4(ap),r7
            addl3 *__CMI_scratch_ram[r6],r7,-4(fp)
        movl -4(fp),r0
            ret
            ret

The Ultrix LK linker doesn't allow references off page zero.  So  when
it tries to link the object produced by assembling the above
code, you get the following error message:

%LK-W-UDEFPSC, attempt to reference undefined psect number 255.
	in module test file test.o

The following patch to vax.md is necessary to avoid this problem:

loki-90% rcsdiff -c vax.md
RCS file: vax.md,v
retrieving revision 1.1
diff -c -r1.1 vax.md
*** /tmp/,RCSt1a02861	Thu Jan  5 20:43:46 1989
--- vax.md	Thu Jan  5 20:37:13 1989
***************
*** 1060,1065 ****
--- 1060,1069 ----
    operands[2] = negate_rtx (QImode, operands[2]);
  }")
  
+ ;; The moval 0[%1],%0 hack below blows up 
+ ;; the LK linker under ultrix, as addressing off 
+ ;; page zero is not allowed.
+ ;;
  (define_insn "ashlsi3"
    [(set (match_operand:SI 0 "general_operand" "=g")
  	(ashift:SI (match_operand:SI 1 "general_operand" "g")
***************
*** 1075,1084 ****
        int i = INTVAL (operands[2]);
        if (i == 1)
  	return \"addl3 %1,%1,%0\";
!       if (i == 2)
  	return \"moval 0[%1],%0\";
        if (i == 3)
! 	return \"movad 0[%1],%0\";
      }
    return \"ashl %2,%1,%0\";
  }")
--- 1079,1088 ----
        int i = INTVAL (operands[2]);
        if (i == 1)
  	return \"addl3 %1,%1,%0\";
!       /*if (i == 2)
  	return \"moval 0[%1],%0\";
        if (i == 3)
! 	return \"movad 0[%1],%0\";*/
      }
    return \"ashl %2,%1,%0\";
  }")
loki-91% 


-- Bill Nesheim; Thinking Machines Corporation, Cambridge, MA +1 617-876-1111
   nesheim@think.com, {harvard,bloom-beacon,topaz}!think!nesheim