Package: gcc-4.1
Version: 4.1.2-5
Severity: grave
Tags: patch
Justification: breaks the glibc
Hi,
You are already aware of the problem, but I think it is better to
summarize it here to get an history of the problem.
GCC generates wrong code on hppa when TLS registers are used. This is
due to a bug in __attribute__ ((tls_model ())) which doesn't express
that it uses r19 or r27.
Here is a small test case for the problem:
extern __thread int __libc_errno __attribute__ ((tls_model (initial-exec)));
extern void free (void *__ptr) __attribute__ ((__nothrow__));
void test(int *p)
{
free (p);
__libc_errno = 25;
}
And the corresponding assembly code:
test:
test():
0: 6b c2 3f d9 stw rp,-14(sp)
4: 6f c4 00 80 stw,ma r4,40(sp)
8: e8 40 00 00 b,l 10 test+0x10,rp
8: R_PARISC_PCREL17Ffree
c: 6b d3 3f c1 stw r19,-20(sp)
10: 2a 60 00 00 addil L%0,r19,r1
10: R_PARISC_LTOFF_TP21L__libc_errno
14: 48 3c 00 00 ldw 0(r1),ret0
14: R_PARISC_LTOFF_TP14R__libc_errno
18: 34 15 00 32 ldi 19,r21
1c: 03 60 08 b4 mfctl tr3,r20
20: 0b 94 0a 14 add,l r20,ret0,r20
24: 0e 95 12 80 stw r21,0(r20)
28: 4b c2 3f 59 ldw -54(sp),rp
2c: e8 40 c0 00 bv r0(rp)
30: 4f c4 3f 81 ldw,mb -40(sp),r4
There is a missing a save/restore of the PIC register around the call to
free.
The attached patch fixes the problem, it has been submitted upstream and
almost accepted (just a typo in the Changelog to fix).
I have rebuilt gcc with it, and then rebuilt the glibc with the rebuilt
gcc. The bug is fixed, and there is no regression in the testsuite.
Bye,
Aurelien
PS: Thanks to Carlos O'Donell for his help in the debugging process.
-- System Information:
Debian Release: lenny/sid
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.18-4-xen-amd64 (SMP w/2 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages gcc-4.1 depends on:
ii binutils 2.17cvs20070426-4 The GNU assembler, linker and bina
ii cpp-4.14.1.2-5 The GNU C preprocessor
ii gcc-4.1-base 4.1.2-5 The GNU Compiler Collection (base
ii libc6 2.5-5 GNU C Library: Shared libraries
ii libgcc11:4.1.2-5 GCC support library
Versions of packages gcc-4.1 recommends:
ii libc6-dev 2.5-5 GNU C Library: Development Librari
ii libmudflap0-dev 4.1.2-5GCC mudflap support libraries (dev
-- no debconf information
hppa-caller-save-pic-tls.dpatch
Description: application/shellscript