Bug 51456 - gcc-4.5.3 ARM misaligned relocation for __gxx_personality_v0 in libstdc++
Summary: gcc-4.5.3 ARM misaligned relocation for __gxx_personality_v0 in libstdc++
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.5.3
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-07 19:37 UTC by junkmailnotread
Modified: 2011-12-30 18:51 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description junkmailnotread 2011-12-07 19:37:41 UTC
gcc-4.5.3 cross-compiled for ARM generates a misaligned relocation for __gxx_personality_v0 in libstdc++.

This was found when running Mozilla Fennec, but also occurs with trivial programs linked against libstdc++ such as Hello World.

C file hello.c contains:

#include <stdio.h>
int main(void)
{
printf("hello world\n");
return (0);
}

Compiled on an x86_64 host as follows:

% arm-softfloat-linux-gnueabi-gcc -o hello hello.c -lstdc++
% 

Run on an ARM target (iPAQ hx4700) produces the following:

# ./hello
Bus error
# 

Adding ld.so debug produces the following:

# export LD_DEBUG=all
# ./hello
<snip>
       682:     
       682:     relocation processing: /lib/libstdc++.so.6 (lazy)
       682:     symbol=__gxx_personality_v0;  lookup in file=./hello [0]
       682:     symbol=__gxx_personality_v0;  lookup in file=/lib/libstdc++.so.6 [0]
       682:     binding file /lib/libstdc++.so.6 [0] to /lib/libstdc++.so.6 [0]: normal symbol `__gxx_personality_v0' [CXXABI_1.3]
Bus error
# 

Running objdump on the host shows the misaligned symbol:

% arm-softfloat-linux-gnueabi-objdump -R /usr/lib/gcc/arm-softfloat-linux-gnueabi/4.5.3/libstdc++.so.6.0.14 | fgrep __gxx_personality_v0
00107afb R_ARM_ABS32       __gxx_personality_v0
00124848 R_ARM_JUMP_SLOT   __gxx_personality_v0
% 

The version information returned by gcc-4.5.3 is the following:

% arm-softfloat-linux-gnueabi-gcc -v
Using built-in specs.
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/arm-softfloat-linux-gnueabi/gcc-bin/4.5.3/arm-softfloat-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/arm-softfloat-linux-gnueabi/4.5.3/lto-wrapper
Target: arm-softfloat-linux-gnueabi
Configured with: /var/tmp/portage/cross-arm-softfloat-linux-gnueabi/gcc-4.5.3-r1/work/gcc-4.5.3/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/arm-softfloat-linux-gnueabi/gcc-bin/4.5.3 --includedir=/usr/lib/gcc/arm-softfloat-linux-gnueabi/4.5.3/include --datadir=/usr/share/gcc-data/arm-softfloat-linux-gnueabi/4.5.3 --mandir=/usr/share/gcc-data/arm-softfloat-linux-gnueabi/4.5.3/man --infodir=/usr/share/gcc-data/arm-softfloat-linux-gnueabi/4.5.3/info --with-gxx-include-dir=/usr/lib/gcc/arm-softfloat-linux-gnueabi/4.5.3/include/g++-v4 --host=x86_64-pc-linux-gnu --target=arm-softfloat-linux-gnueabi --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --without-ppl --without-cloog --disable-lto --with-float=soft --disable-nls --with-system-zlib --disable-werror --enable-secureplt --disable-multilib --enable-libmudflap --disable-libssp --disable-libgomp --with-python-dir=/share/gcc-data/arm-softfloat-linux-gnueabi/4.5.3/python --enable-checking=release --disable-libgcj --enable-languages=c,c++ --with-sysroot=/usr/arm-softfloat-linux-gnueabi --disable-bootstrap --enable-__cxa_atexit --enable-clocale=gnu --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.5.3-r1 p1.0, pie-0.4.5'
Thread model: posix
gcc version 4.5.3 (Gentoo 4.5.3-r1 p1.0, pie-0.4.5) 
%
Comment 1 Andrew Pinski 2011-12-07 19:43:26 UTC
What version of glibc are you using?  glibc should be handling the unaligned relocation correctly.  Also GCC is correct here in using the unaligned relocation.
Comment 2 Andrew Pinski 2011-12-07 19:44:09 UTC
See http://gcc.gnu.org/ml/gcc-help/2005-07/msg00325.html for a problem against MIPS for the same unaligned relocation.
Comment 3 junkmailnotread 2011-12-07 20:31:02 UTC
I'm using glibc-2.12.2
Comment 4 Richard Earnshaw 2011-12-08 10:41:09 UTC
http://infocenter.arm.com/help/topic/com.arm.doc.ihi0044d/IHI0044D_aaelf.pdf
(in section 4.7.1.3) states that R_ARM_ABS32 should work for a relocation place with any alignment.
Comment 5 junkmailnotread 2011-12-08 23:46:37 UTC
The problem is also present with glibc-2.13

Thanks for the PDF reference. If R_ARM_ABS32 has no alignment requirement then this must be a glibc bug.
Comment 6 Sergei Trofimovich 2011-12-30 17:59:17 UTC
> (in section 4.7.1.3) states that R_ARM_ABS32 should work for a relocation place
> with any alignment.

Currently glibc's relocation setup code does not attempt to handle unaligned relocations. And I think it makes sense.

Does gcc generate slow unaligned reads from such relocations as well?
Comment 7 Sergei Trofimovich 2011-12-30 18:51:35 UTC
Just for reference. Proposed fix in glibc:

http://old.nabble.com/-patch--handle-unaligned-arm-abs-relocs-td32964712.html