Bug 214440 - unaligned access in ld.so when linking dmraid
Summary: unaligned access in ld.so when linking dmraid
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: glibc
Version: 5.0
Hardware: ia64
OS: Linux
Target Milestone: ---
: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
Depends On:
TreeView+ depends on / blocked
Reported: 2006-11-07 17:42 UTC by Bryn M. Reeves
Modified: 2008-01-28 15:47 UTC (History)
1 user (show)

Clone Of:
Last Closed: 2006-11-07 22:03:57 UTC

Attachments (Terms of Use)
patch to work around unaligned accesses in ld (1.16 KB, patch)
2006-11-07 17:58 UTC, Bryn M. Reeves
no flags Details | Diff

Description Bryn M. Reeves 2006-11-07 17:42:54 UTC
Split off from bug 202096 (ia64: unaligned accesses during dmraid execution at

ld generates unaligned access faults on ia64 linking dmraid.so to dmraid.

The faulting instruction lies in _dl_relocate_object:

dmraid(4716): unaligned access to 0x20000000000ae0be, ip=0x2000000000018080

Breakpoint 2, 0x2000000000018090 in _dl_relocate_object () from
(gdb) bt
#0  0x2000000000018090 in _dl_relocate_object () from /lib/ld-linux-ia64.so.2
#1  0x2000000000008450 in dl_main () from /lib/ld-linux-ia64.so.2
#2  0x200000000002c5e0 in _dl_sysdep_start () from /lib/ld-linux-ia64.so.2
#3  0x2000000000004bf0 in _dl_start () from /lib/ld-linux-ia64.so.2
#4  0x2000000000001590 in _start () from /lib/ld-linux-ia64.so.2

Intel further pinned this down to:


elf_machine_rela_relative (Elf64_Addr l_addr, const Elf64_Rela *reloc,
                           void *const reloc_addr_arg)
  Elf64_Addr *const reloc_addr = reloc_addr_arg;
  /* ??? Ignore MSB and Instruction format for now.  */
  assert (ELF64_R_TYPE (reloc->r_info) == R_IA64_REL64LSB);

  *reloc_addr += l_addr; <--------

It sems like the faults happen relocating an array of packed structs:

struct format_member {
        const unsigned short offset;
        const unsigned char flags;
        const char *msg;
} __attribute__ ((packed));

static struct format_member format_member[] = {

A patch was pasted into bug 202096 that makes _dl_relocate_object check for
unaligned accesses and work around them - will attach here also.

Comment 1 Bryn M. Reeves 2006-11-07 17:48:53 UTC
The RHEL5 version of the dmraid issue is in bug 211150

Comment 2 Jakub Jelinek 2006-11-07 17:49:56 UTC
I think there is no way we want to slow down the dynamic linker to workaround
buggy apps.  An array of packed struct requiring runtime relocations is simply
a big no no.

Comment 3 Bryn M. Reeves 2006-11-07 17:58:04 UTC
Created attachment 140576 [details]
patch to work around unaligned accesses in ld

Comment 4 Jakub Jelinek 2006-11-07 22:03:57 UTC
Unaligned relocations are extremely rare and the kernel has unaligned trap
handler which handles it just fine.
1) dmraid needs to be fixed not to have unaligned relocations
2) kernel should at least rate limit the unaligned trap messages if it is not
doing that
On IA-64 prelink isn't supported and for larger libraries
elf_machine_rela_relative inline is called really many times (e.g. libgcj.so.7rh
alone has 347305 relative relocations), adding a conditional jump there will
show up quite measurably.  Furthermore, there isn't anything special on relative
relocations, so we'd need change all other non-instruction relocations too.
It is much better to leave the very rare case to the unaligned trap handler and
attempt that at least in the libraries we ship unaligned relocations aren't
used or used very rarely.

Note You need to log in before you can comment on or make changes to this bug.