[llvm] c5d8bd5 - [llvm-objcopy] Fix section group flag read/write when operating on a cross-endian object file
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 26 15:09:20 PDT 2021
Author: Fangrui Song
Date: 2021-07-26T15:09:15-07:00
New Revision: c5d8bd5a35cbd325c6ccd42afa91bad06d261f07
URL: https://github.com/llvm/llvm-project/commit/c5d8bd5a35cbd325c6ccd42afa91bad06d261f07
DIFF: https://github.com/llvm/llvm-project/commit/c5d8bd5a35cbd325c6ccd42afa91bad06d261f07.diff
LOG: [llvm-objcopy] Fix section group flag read/write when operating on a cross-endian object file
Added:
Modified:
llvm/tools/llvm-objcopy/ELF/Object.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-objcopy/ELF/Object.cpp b/llvm/tools/llvm-objcopy/ELF/Object.cpp
index 91a73f2111ae..ba91d08e5540 100644
--- a/llvm/tools/llvm-objcopy/ELF/Object.cpp
+++ b/llvm/tools/llvm-objcopy/ELF/Object.cpp
@@ -1187,7 +1187,7 @@ template <class ELFT>
Error ELFSectionWriter<ELFT>::visit(const GroupSection &Sec) {
ELF::Elf32_Word *Buf =
reinterpret_cast<ELF::Elf32_Word *>(Out.getBufferStart() + Sec.Offset);
- *Buf++ = Sec.FlagWord;
+ support::endian::write32<ELFT::TargetEndianness>(Buf++, Sec.FlagWord);
for (SectionBase *S : Sec.GroupMembers)
support::endian::write32<ELFT::TargetEndianness>(Buf++, S->Index);
return Error::success();
@@ -1517,7 +1517,8 @@ Error ELFBuilder<ELFT>::initGroupSection(GroupSection *GroupSec) {
reinterpret_cast<const ELF::Elf32_Word *>(GroupSec->Contents.data());
const ELF::Elf32_Word *End =
Word + GroupSec->Contents.size() / sizeof(ELF::Elf32_Word);
- GroupSec->setFlagWord(*Word++);
+ GroupSec->setFlagWord(
+ support::endian::read32<ELFT::TargetEndianness>(Word++));
for (; Word != End; ++Word) {
uint32_t Index = support::endian::read32<ELFT::TargetEndianness>(Word);
Expected<SectionBase *> Sec = SecTable.getSection(
More information about the llvm-commits
mailing list