This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
A simple testcase with just movl $foo, %edi foo: will cause an unaligned access in gold. A backtrace found with -fsanitize=alignment is attached. The attached patch avoids the unaligned access. Cheers, Rafael 2015-06-07 Rafael Ãvila de EspÃndola <rafael.espindola@gmail.com> * elfcpp_swap.h (Swap::writeval): Avoid unaligned access.
Attachment:
trace
Description: Binary data
diff --git a/elfcpp/elfcpp_swap.h b/elfcpp/elfcpp_swap.h
index 5b9a915..cddc0b3 100644
--- a/elfcpp/elfcpp_swap.h
+++ b/elfcpp/elfcpp_swap.h
@@ -234,7 +234,10 @@ struct Swap
static inline void
writeval(Valtype* wv, Valtype v)
- { *wv = Convert<size, big_endian>::convert_host(v); }
+ {
+ Valtype T = Convert<size, big_endian>::convert_host(v);
+ memcpy(wv, &T, sizeof(T));
+ }
static inline Valtype
readval(const unsigned char* wv)
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |