diff options
author | Davide Italiano <davide@freebsd.org> | 2018-11-06 17:11:34 +0000 |
---|---|---|
committer | Davide Italiano <davide@freebsd.org> | 2018-11-06 17:11:34 +0000 |
commit | b37f1ec86131d3963177bffc22449b881db3f98a (patch) | |
tree | df406c63c94ebd6b017402a38b0a54e22827632c /lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | |
parent | db272b3720c4ebd69b077c546ad0b0b18e4e8e00 (diff) | |
download | bcm5719-llvm-b37f1ec86131d3963177bffc22449b881db3f98a.tar.gz bcm5719-llvm-b37f1ec86131d3963177bffc22449b881db3f98a.zip |
[ObjectFileELF] Fix misaligned read/writes caught by UBSan.
llvm-svn: 346244
Diffstat (limited to 'lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp')
-rw-r--r-- | lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
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<uint64_t *>( 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<uint32_t *>( data_buffer_sp->GetBytes() + rel_section->GetFileOffset() + ELFRelocation::RelocOffset32(rel)); - *dst = truncated_addr; + memcpy(dst, &truncated_addr, sizeof(uint32_t)); } break; } |