unaligned access on ia64

Zhang, Yanmin yanmin_zhang at linux.intel.com
Fri Dec 8 04:46:22 UTC 2006


There are many unaligned access reported by FedoraCore 6 on ia64.

See the report at https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=202096.

Because relocation entries might point to unaligned addresses, ld.so
might cause unaligned access when accessing such addresses.

Besides dmraid, other applications, including anaconda (python), also cause
unaligned access, so it's better to fix it in glibc.

I worked out a patch to fix it. The patch was also posted to the bug report.

Could anybody provide comments?

Thanks,
Yanmin

---

--- glibc-2.5-20061008T1257/sysdeps/ia64/dl-machine.h	2006-12-08 01:26:54.000000000 +0800
+++ glibc-2.5-20061008T1257_bak/sysdeps/ia64/dl-machine.h	2006-12-08 02:33:02.000000000 +0800
@@ -477,16 +477,25 @@ elf_machine_rela (struct link_map *map,
    can be skipped.  */
 #define ELF_MACHINE_REL_RELATIVE 1
 
+union ia64_unaligned_data {
+	Elf64_Addr l_addr;
+} __attribute__ ((packed));
+
 auto inline void
 __attribute ((always_inline))
 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;
+  if (((long)reloc_addr_arg) & 0x7) {
+    union ia64_unaligned_data *const lpdata = reloc_addr_arg;
+    lpdata->l_addr += l_addr;
+  } else {
+    Elf64_Addr *const reloc_addr = reloc_addr_arg;
+    *reloc_addr += l_addr;
+  }
 }
 
 /* Perform a RELATIVE reloc on the .got entry that transfers to the .plt.  */




More information about the fedora-devel-list mailing list