Hi,

Last may, after getting a gcc3 internal compiler error bugreport
handed back to me, I decided to see how big a hole I could shoot
in my foot by trying to switch to gcc4.

At that time unaware of Marco Peereboom's gcc4 timing page stating
the issues with alpha and gcc4, I independanly came to the similar
conclusions:
Yes, the kernel needed a tweak and it was trivial.
And furthermore, yes, after userland built fine and it was completely
borked due to ld.so putting multiple clogs into the cogs.

Not to be deterred I started to kick ld.so around for a bit.
compile with -O1: still no go.
compile with -O0: working ld.so.

Big cheer, I now had an fully ggc4 compiled base. 

Further kicking at the ld.so sources determined that only the files
alpha/rtld_machine.c and dl_prebind.c needed to be compiled with
-O0. The rest could be compiled with the default -O2 and still
result in a working ld.so.

Finally after cursing the lack of information I could retrieve from
either running something from gdb (there did not deem to be any
process yet to debug and placing breakpoints on the entrypoints of
ld.s also did not seem to give any action) or by ktracing (which
did nothing between returning from exec and generating a segv) a
simple binary with a broken ld.so (in a chrooted environment) did
not give me any more insight into what might have been happening,
but after reading the kernel sources for some intuitive reason still
completely beyond any logic I can reproduce I decided to split up
the problematic source files.

For some obscure reason this gave successes. After splitting up
alpha/rtld_machine.c into 2 or mor parts, any combination where the
1st and the 3rd function (_dl_md_reloc and _dl_md_reloc_got) were
not in the same source allowed the split-up sources to be compiled
without breaking ld.so. Looking with my untrained eye at the generated
assembly or the dissasembled objects did not give me any clue as
to why this was happening.

Recently I found a new spot of available time and tried the same
trick with the other problematic file (dl_prebind.c). Here a split
where the second and the third function (prebind_load_exe and
prebind_load_fd) needed to be in separate source/object files resulted
in a -O2 compilable situation. The rest of the functions could be
put with either one of them or even in one or more separate functions
without any influnence on the result.

Therfore my question is: Does anyone have an idea about what is
happening or at least how I can find out what the issue is?

As a last issue, after getting ld.so running I found an onther issue
with gcc4 built userland: anything using libkvm gets a unaligned
access in the code to avoid alignment issues (around kvm.c line
780). compiling with -fno-builtin removed this issue but I have not
yet looked more closely at it.

With these workarounds in place I have been running fine on several 
generations of current between then and now.

Ob-dmesg for those interested:

[ using 630552 bytes of bsd ELF symbol table ]
consinit: not using prom console
Copyright (c) 1982, 1986, 1989, 1991, 1993
        The Regents of the University of California.  All rights reserved.
Copyright (c) 1995-2011 OpenBSD. All rights reserved.  http://www.OpenBSD.org

OpenBSD 5.0-current (GENERIC) #0: Tue Sep 27 21:37:28 CEST 2011
    janjaap@alf:/forest/trees/src/sys/arch/alpha/compile/GENERIC
Digital AlphaPC 164SX 533 MHz
8192 byte page size, 1 processor.
real mem = 536870912 (512MB)
rsvd mem = 1966080 (1MB)
avail mem = 517832704 (493MB)
mainbus0 at root
cpu0 at mainbus0: ID 0 (primary), PCA56-2 (unknown minor type 2)
cpu0: architecture extensions: 1<BWX>
cia0 at mainbus0: DECchip 2117x Core Logic Chipset (Pyxis), pass 1
cia0: extended capabilities: 1<BWEN>
cia0: using BWX for PCI config and bus access
pci0 at cia0 bus 0
vga0 at pci0 dev 6 function 0 "Matrox MGA G200 PCI" rev 0x01
wsdisplay0 at vga0 mux 1
wsdisplay0: screen 0-5 added (80x25, vt100 emulation)
em0 at pci0 dev 7 function 0 "Intel PRO/1000MT (82541GI)" rev 0x00: eb164 irq 
10, address 00:0e:0c:51:3d:a0
sio0 at pci0 dev 8 function 0 "Contaq Microsystems CY82C693U ISA" rev 0x00
pciide0 at pci0 dev 8 function 1 "Contaq Microsystems CY82C693U ISA" rev 0x00: 
DMA, channel 0 wired to compatibility
pciide0: channel 0 disabled (no drives)
pciide1 at pci0 dev 8 function 2 "Contaq Microsystems CY82C693U ISA" rev 0x00: 
no DMA, channel 0 wired to compatibility
wd0 at pciide1 channel 0 drive 0: <Maxtor 6Y160P0>
wd0: 16-sector PIO, LBA48, 156334MB, 320173056 sectors
wd1 at pciide1 channel 0 drive 1: <WDC WD800JB-00JJA0>
wd1: 16-sector PIO, LBA, 76319MB, 156301488 sectors
wd0(pciide1:0:0): using PIO mode 4
wd1(pciide1:0:1): using PIO mode 4
ohci0 at pci0 dev 8 function 3 "Contaq Microsystems CY82C693U ISA" rev 0x00: 
couldn't map interrupt
uhci0 at pci0 dev 9 function 0 "VIA VT83C572 USB" rev 0x61: eb164 irq 8
uhci1 at pci0 dev 9 function 1 "VIA VT83C572 USB" rev 0x61: eb164 irq 12
ehci0 at pci0 dev 9 function 2 "VIA VT6202 USB" rev 0x63: eb164 irq 16
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 "VIA EHCI root hub" rev 2.00/1.00 addr 1
isa0 at sio0
isadma0 at isa0
com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
com0: console
com1 at isa0 port 0x2f8/8 irq 3: ns16550a, 16 byte fifo
pckbc0 at isa0 port 0x60/5
pckbd0 at pckbc0 (kbd slot)
pckbc0: using irq 1 for kbd slot
wskbd0 at pckbd0 mux 1
wskbd0: connecting to wsdisplay0
pcppi0 at isa0 port 0x61
spkr0 at pcppi0
lpt0 at isa0 port 0x3bc/4 irq 7
fdc0 at isa0 port 0x3f0/6 irq 6 drq 2
isapnp0 at isa0 port 0x279: read port 0x203
ep0 at isapnp0 "3Com 3C509B EtherLink III, TCM5095, PNP80F7, " port 0x210/16 
irq 5: address 00:10:5a:da:70:fa, utp (default utp)
mcclock0 at isa0 port 0x70/2: mc146818 or compatible
usb1 at uhci0: USB revision 1.0
uhub1 at usb1 "VIA UHCI root hub" rev 1.00/1.00 addr 1
usb2 at uhci1: USB revision 1.0
uhub2 at usb2 "VIA UHCI root hub" rev 1.00/1.00 addr 1
stray isa irq 3
stray isa irq 5
uhidev0 at uhub2 port 1 configuration 1 interface 0 "Logitech USB Optical 
Mouse" rev 2.00/53.00 addr 2
uhidev0: iclass 3/1
ums0 at uhidev0: 3 buttons, Z dir
wsmouse0 at ums0 mux 0
uhub3 at uhub2 port 2 "ALCOR Generic USB Hub" rev 1.10/3.12 addr 3
vscsi0 at root
scsibus0 at vscsi0: 256 targets
softraid0 at root
scsibus1 at softraid0: 256 targets
root on wd0a swap on wd0b dump on wd0b
stray isa irq 3
wsdisplay0: screen 8 added (80x25, vt100 emulation)
wsdisplay0: screen 9 added (80x25, vt100 emulation)
wsdisplay0: screen 4 deleted
wsdisplay0: screen 5 deleted
wsdisplay0: screen 4 added (80x40, vt100 emulation)
wsdisplay0: screen 5 added (80x40, vt100 emulation)
wsdisplay0: screen 6 added (80x40, vt100 emulation)
wsdisplay0: screen 7 added (80x40, vt100 emulation)
wsdisplay0: screen 10 added (80x50, vt100 emulation)
wsdisplay0: screen 11 added (80x50, vt100 emulation)
wsmouse0 detached
ums0 detached
uhidev0 detached
uhidev0 at uhub2 port 1 configuration 1 interface 0 "Logitech USB Optical 
Mouse" rev 2.00/53.00 addr 2
uhidev0: iclass 3/1
ums0 at uhidev0: 3 buttons, Z dir
wsmouse0 at ums0 mux 0

        Janjaap van Velthooven
--  ________________________________________
   / __/ /_    / ______/ /_  __/ __/ /___  /
  / /_  __/___/_/_  /___  / / __/ /___  / /          [email protected]
 /___/_/_________/_____/_/_/_/_______/_/_/

Reply via email to