diff options
author | Zachary Turner <zturner@google.com> | 2014-06-25 05:42:32 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2014-06-25 05:42:32 +0000 |
commit | 736d4d85db80d2583ac12daa1eac59b0c010e1af (patch) | |
tree | cadf1e3ed5632fe60feb4b1c438b6275e6351a26 /lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | |
parent | 6804d450cdbb7c44c392c7009d1f2c4ca3d04ce6 (diff) | |
download | bcm5719-llvm-736d4d85db80d2583ac12daa1eac59b0c010e1af.tar.gz bcm5719-llvm-736d4d85db80d2583ac12daa1eac59b0c010e1af.zip |
Replace GCC-specific intrinsic with portable alternative.
Not all supported compilers have GCC intrinsics, so this patch
uses the correct portable alternative.
Additionally, this patch fixes an off-by-one error. __builtin_ffs
returns the 1-based index of the least-significant 1-bit, but the
function expects the base 2 logarithm of the number, which is
equivalent to the 0-based index of the least-significant 1-bit.
Reviewed by: Keno Fischer
Differential Revision: http://reviews.llvm.org/D4284
llvm-svn: 211669
Diffstat (limited to 'lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp')
-rw-r--r-- | lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 688b64cca81..bd733c8466b 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -30,6 +30,7 @@ #include "lldb/Host/Host.h" #include "llvm/ADT/PointerUnion.h" +#include "llvm/Support/MathExtras.h" #define CASE_AND_STREAM(s, def, width) \ case def: s->Printf("%-*s", width, #def); break; @@ -1227,6 +1228,9 @@ ObjectFileELF::CreateSections(SectionList &unified_section_list) break; } + elf::elf_xword log2align = (header.sh_addralign==0) + ? 0 + : llvm::Log2_64(header.sh_addralign); SectionSP section_sp (new Section(GetModule(), // Module to which this section belongs. this, // ObjectFile to which this section belongs and should read section data from. SectionIndex(I), // Section ID. @@ -1236,7 +1240,7 @@ ObjectFileELF::CreateSections(SectionList &unified_section_list) vm_size, // VM size in bytes of this section. header.sh_offset, // Offset of this section in the file. file_size, // Size of the section as found in the file. - __builtin_ffs(header.sh_addralign), // Alignment of the section + log2align, // Alignment of the section header.sh_flags)); // Flags for this section. if (is_thread_specific) |