Skip to contentSkip to conversation

new g++/exceptions problem

parisc-linux Paul Bame 3 participants 4 messages Jun 16, 2001 – Jun 17, 2001

lore
Share & tools
lore

Paul Bame

author
#0 lore raw

I built apt against the new exception-handling
compilers (pehc:~taggart/newcompilers-20010615)
and now all the apt utilities bus error right away. This stuff can be found installed on gsyprf11 built from ~bame/apt. So far I know

!!die_if_kernel: apt-get(7797): Unaligned data reference 28

IAOQ: 000000004000ccab IIR: 0cc41280
ldd says this code in ld.so.1:

libapt-pkg-libc6.2-3.so.3.2 => /usr/lib/libapt-pkg-libc6.2-3.so.3.2 (0x4002b000) libstdc++.so.3 => /usr/lib/libstdc++.so.3 (0x40120000)
libm.so.6 => /lib/libm.so.6 (0x40201000)
libc.so.6 => /lib/libc.so.6 (0x40291000)
/lib/ld.so.1 => /lib/ld.so.1 (0x40000000)

The offending code is:

0000c7a0 <_dl_relocate_object>:
...

    cbf8:       0a cc 0a 16     add,l r12,r22,r22
    cbfc:       0c a0 10 97     ldw  0(sr0,r5),r23
...
    cc04:       0c e0 10 94     ldw  0(sr0,r7),r20
...
    cc9c:       2a 60 00 00     addil 0,r19,%r1
    cca0:       48 21 0a f0     ldw 578(sr0,r1),r1
    cca4:       08 a1 28 80     cmpclr,= r1,r5,r0
--> cca8:       0c c4 12 80     stw  r4,0(sr0,r6)
    cc14:       0a 97 0a 06     add,l r23,r20,r6

r6 is 00000000401e51ee which refers to libstdc++ offset c51ee:

16 .data 00002f2c 000c22b0 000c22b0 000b22b0 2**4
CONTENTS, ALLOC, LOAD, DATA
17 .eh_frame 0001254c 000c51dc 000c51dc 000b51dc 2**2
CONTENTS, ALLOC, LOAD, DATA
18 .gcc_except_table 0000298c 000d7728 000d7728 000c7728 2**2
CONTENTS, ALLOC, LOAD, DATA

so it's inside the exception-handler frame. My wild guess is the dynamic linker is trying to handle a new type of symbol which refers to the new exception stuff which is for some reason not 4-byte aligned, but this surely ain't my expertise area!

	-P
author
#1 lore raw

=
= I built apt against the new exception-handling

The following shows what appears to be the same problem:

$ cat hello.c
#include <stdio.h>
int main() {printf("hello world\n");}
$ g++ -o hello hello.c
$ ./hello
Bus error
$

which makes me think something in the C++ exception initialization is the culprit -- another wild guess

#2 lore raw
In reply to Paul Bame
Quoted 3 lines

I built apt against the new exception-handling
compilers (pehc:~taggart/newcompilers-20010615)
and now all the apt utilities bus error right away. This stuff can

There is a known issue with gcc 3.0 and glibc:
<http://gcc.gnu.org/ml/gcc-bugs/2001-06/msg00770.html>. It involves the change in exception handling. Possibly, this is what is bitting.

Dave

Signature · 2 lines
J. David Anglin                                  [email protected]
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)
#3 lore raw
In reply to Paul Bame
Quoted 5 lines · Paul Bame

so it's inside the exception-handler frame. My wild guess is the dynamic linker is trying to handle a new type of symbol which refers to the new exception stuff which is for some reason not 4-byte aligned

Yes, the new exception code puts R_PARISC_DIR32 relocs at unaligned addresses. "objdump -r libstdc++.so" reveals

Relocation section '.rela.eh_frame' at offset 0x37024 contains 1611 entries:

  Offset    Info  Type            Symbol's Value  Symbol's Name          Addend
  000c167e  4da01 R_PARISC_DIR32        00056914  __gxx_personality_v0      + 0
  000c1690  00d01 R_PARISC_DIR32        0003fe40  .text                     + 5114
  000c1699  01301 R_PARISC_DIR32        000cede4  .gcc_except_table         + 0

etc.

Seems like a change in the dynamic linker is needed to handle this situation. Something like the following should do it for you.

hppa/dl-machine.h renamed from hppa/dl-machine.h~ +10 -1
@@ -536,7 +536,16 @@
       if (map == &_dl_rtld_map)
 	return;
 #endif
-      /* Otherwise, nothing more to do here. */
+      /* .eh_frame can have unaligned relocs.  */
+      if (reloc_addr & 3)
+	{
+	  char *rel_addr = (char *) reloc_addr;
+	  rel_addr[0] = value >> 24;
+	  rel_addr[1] = value >> 16;
+	  rel_addr[2] = value >> 8;
+	  rel_addr[3] = value >> 0;
+	  return;
+	}
       break;
 
     case R_PARISC_PLABEL32: