Bug 214440 - unaligned access in ld.so when linking dmraid
unaligned access in ld.so when linking dmraid
Status: CLOSED WONTFIX
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: glibc (Show other bugs)
5.0
ia64 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-11-07 12:42 EST by Bryn M. Reeves
Modified: 2008-01-28 10:47 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-11-07 17:03:57 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


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

  None (edit)
Description Bryn M. Reeves 2006-11-07 12:42:54 EST
Split off from bug 202096 (ia64: unaligned accesses during dmraid execution at
startup)

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
/lib/ld-linux-ia64.so.2
(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:

sysdeps/ia64/dl-machine.h.

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 12:48:53 EST
The RHEL5 version of the dmraid issue is in bug 211150
Comment 2 Jakub Jelinek 2006-11-07 12:49:56 EST
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 12:58:04 EST
Created attachment 140576 [details]
patch to work around unaligned accesses in ld
Comment 4 Jakub Jelinek 2006-11-07 17:03:57 EST
Unaligned relocations are extremely rare and the kernel has unaligned trap
handler which handles it just fine.
So, IMHO:
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.