Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 394237 - sys-libs/glibc-2.13-r4 ARM bus error when relocating a misaligned R_ARM_ABS32 relocation
Summary: sys-libs/glibc-2.13-r4 ARM bus error when relocating a misaligned R_ARM_ABS32...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: ARM Linux
: Normal normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL: http://sourceware.org/ml/libc-ports/2...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-10 12:40 UTC by junkmailnotread
Modified: 2012-08-12 05:47 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Bug fix for misaligned R_ARM_ABS32 relocation (glibc-2.13-r4.patch,765 bytes, patch)
2011-12-10 12:43 UTC, junkmailnotread
Details | Diff
glibc arm reloc (glibc-unaligned-abs-reloc.patch,931 bytes, patch)
2011-12-10 19:31 UTC, SpanKY
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description junkmailnotread 2011-12-10 12:40:51 UTC
glibc-2.13-r4 cross-compiled for ARM causes a bus error when relocating a misaligned R_ARM_ABS32 relocation for __gxx_personality_v0 in libstdc++.

The gcc developers assert that R_ARM_ABS32 has no alignment requirement, and hence this is not a gcc bug:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51456

The bug is in glibc-ports-2.13/sysdeps/arm/dl-machine.h line 421:
            *reloc_addr += value;

The bug was also present in glibc-2.12.2. The bug is apparently still present in glibc-2.14.1 (according to visual inspection of the source).

Here is the emerge --info output:

# emerge --info =cross-arm-softfloat-linux-gnueabi/glibc-2.13-r4
Portage 2.1.10.11 (default/linux/amd64/10.0/no-multilib, gcc-4.5.3, glibc-2.13-r4, 3.1.0 x86_64)
=================================================================
                        System Settings
=================================================================
System uname: Linux-3.1.0-x86_64-Intel-R-_Core-TM-2_Duo_CPU_E6750_@_2.66GHz-with-gentoo-2.0.3
Timestamp of tree: Thu, 08 Dec 2011 10:15:01 +0000
app-shells/bash:          4.1_p9
dev-java/java-config:     2.1.11-r3
dev-lang/python:          2.7.2-r3, 3.1.4-r3
dev-util/cmake:           2.8.4-r1
dev-util/pkgconfig:       0.26
sys-apps/baselayout:      2.0.3
sys-apps/openrc:          0.9.4
sys-apps/sandbox:         2.5
sys-devel/autoconf:       2.13, 2.68
sys-devel/automake:       1.9.6-r3, 1.11.1
sys-devel/binutils:       2.21.1-r1
sys-devel/gcc:            4.5.3-r1
sys-devel/gcc-config:     1.4.1-r1
sys-devel/libtool:        2.4-r1
sys-devel/make:           3.82-r1
sys-kernel/linux-headers: 2.6.39 (virtual/os-headers)
sys-libs/glibc:           2.13-r4
Repositories: gentoo x-portage
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA AdobeFlash-10.1 Oracle-BCLA-JavaSE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-pipe -fomit-frame-pointer -O2 -march=core2"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-pipe -fomit-frame-pointer -O2 -march=core2"
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests binpkg-logs distlocks ebuild-locks fixlafiles fixpackages news parallel-fetch protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
FFLAGS=""
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="en_GB"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS="en en_GB"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"
USE="X alsa amd64 berkdb bzip2 cairo cli consolekit cracklib crypt cups cxx dri encode exif fam flac fortran gdbm gif gnutls gpm iconv jpeg lcms mad mmx mng modules mudflap ncurses nls nptl nptlonly nsplugin opengl openmp pam pcre pdf png policykit ppds pppd readline sdl session smp sse sse2 ssl ssse3 svg sysfs tcpd tiff truetype unicode usb xcb xorg xv zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan stage tables krita karbon braindump" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en en_GB" PHP_TARGETS="php5-3" RUBY_TARGETS="ruby18" USERLAND="GNU" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, MAKEOPTS, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

=================================================================
                        Package Settings
=================================================================

cross-arm-softfloat-linux-gnueabi/glibc-2.13-r4 was built with the following:
USE="nls -debug -gd -glibc-omitfp -hardened (-multilib) -profile (-selinux) -vanilla"
CFLAGS="-pipe -O2 -fno-strict-aliasing"
CXXFLAGS="-pipe -O2 -fno-strict-aliasing"

# 

Reproducible: Always

Steps to Reproduce:
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++
% 
Actual Results:  
Run on an ARM target (iPAQ hx4700) as follows:

# ./hello
Bus error
# 

Expected Results:  
# ./hello
hello world
# 

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 x86_64 host shows the misaligned R_ARM_ABS32 relocation:

% 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
%
Comment 1 junkmailnotread 2011-12-10 12:43:25 UTC
Created attachment 295357 [details, diff]
Bug fix for misaligned R_ARM_ABS32 relocation
Comment 2 SpanKY gentoo-dev 2011-12-10 19:31:08 UTC
Created attachment 295409 [details, diff]
glibc arm reloc

i think that change is more complicated than necessary.  try this one instead.
Comment 3 junkmailnotread 2011-12-11 00:26:27 UTC
Yes, my fix was just a quick hack. Your simpler one works too.
Comment 4 SpanKY gentoo-dev 2012-01-01 09:50:10 UTC
i've committed a patch (which is included in glibc-2.14.1-r2):
http://sources.gentoo.org/gentoo/src/patchsets/glibc/2.14.1/6250_all_glibc-2.14-arm-unaligned-reloc.patch?rev=1.1

could you test + confirm that it fixes your issues ?  you can put arbitrary patches into /etc/portage/patches/sys-libs/glibc/ to have them applied automatically when emerging glibc.
Comment 5 junkmailnotread 2012-01-01 18:14:45 UTC
Yes, your 6250 patch fixes it too.

Creating /etc/portage/patches/sys-libs/glibc and copying the 6250 patch into it didn't seem to have any affect; dl-machine.h was not modified after the emerge had started. So I manually applied the 6250 patch to glibc-2.13-r4 during emerge.

I had re-emerged cross-arm-softfloat-linux-gnueabi/gcc since I first filed this bug, so I verified that the R_ARM_ABS32 relocation is still misaligned:

% 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
001089db R_ARM_ABS32       __gxx_personality_v0
0012c848 R_ARM_JUMP_SLOT   __gxx_personality_v0
%

The hello world test program works OK with the patched glibc-2.13-r4.
Comment 6 SpanKY gentoo-dev 2012-01-03 00:34:03 UTC
thanks for verifying.  i'll send it upstream then.