From b37f1ec86131d3963177bffc22449b881db3f98a Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Tue, 6 Nov 2018 17:11:34 +0000 Subject: [ObjectFileELF] Fix misaligned read/writes caught by UBSan. llvm-svn: 346244 --- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp') diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index fd1edcd6a64..1001eaef555 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -2712,7 +2712,8 @@ unsigned ObjectFileELF::ApplyRelocations( uint64_t *dst = reinterpret_cast( data_buffer_sp->GetBytes() + rel_section->GetFileOffset() + ELFRelocation::RelocOffset64(rel)); - *dst = value + ELFRelocation::RelocAddend64(rel); + uint64_t val_offset = value + ELFRelocation::RelocAddend64(rel); + memcpy(dst, &val_offset, sizeof(uint64_t)); } break; } @@ -2738,7 +2739,7 @@ unsigned ObjectFileELF::ApplyRelocations( uint32_t *dst = reinterpret_cast( data_buffer_sp->GetBytes() + rel_section->GetFileOffset() + ELFRelocation::RelocOffset32(rel)); - *dst = truncated_addr; + memcpy(dst, &truncated_addr, sizeof(uint32_t)); } break; } -- cgit v1.2.3