<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">After this commit, one of our internal bots fails these two tests:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">Failing Tests (2):</div><div class="">   LLVM :: Object/Mips/elf-mips64-rel.yaml</div><div class="">   LLVM :: Object/yaml2obj-elf-symbol-basic.yaml</div></blockquote><div class=""><br class=""></div><div class="">It looks like this is due to some wrongly assumed alignment, and some optimization is turning this into a crash only on this machine, while other buildbots seem to run fine.  I was able to reproduce the issue on my machine by adding the following assert (that explicitly checks the assumed alignment) into Support/Endian.h:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">inline value_type read(const void *memory) {<br class="">  assert(((long)memory & ((detail::PickAlignment<value_type, alignment>::value)-1)) == 0);<br class="">  value_type ret;<br class=""><br class="">  memcpy(&ret,<br class="">         LLVM_ASSUME_ALIGNED(memory,<br class="">           (detail::PickAlignment<value_type, alignment>::value)),<br class="">         sizeof(value_type));<br class="">  return byte_swap<value_type, endian>(ret);<br class="">}<br class=""><br class=""></div></blockquote><div class="">Do you think you could take a look into that?</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Kuba</div><br class=""><div><blockquote type="cite" class=""><div class="">On 08 Jul 2015, at 12:12, Simon Atanasyan <<a href="mailto:simon@atanasyan.com" class="">simon@atanasyan.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Author: atanasyan<br class="">Date: Wed Jul  8 05:12:40 2015<br class="">New Revision: 241674<br class=""><br class="">URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D241674-26view-3Drev&d=AwMFAg&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=YDLAtmcVe58ifmG8qRc-1GBwK4OOtXAkMbknBw-s3BY&s=vk8eONiVA9bWjQAyq0bI2v5pTuK8e2BrFQKaEZWbhEA&e=" class="">http://llvm.org/viewvc/llvm-project?rev=241674&view=rev</a><br class="">Log:<br class="">[yaml2obj] Align section content using AddressAlign field's value<br class=""><br class="">Use AddressAlign field's value to properly align sections content in the<br class="">yaml2obj tool. Before this change the yaml2obj ignored AddressAlign and<br class="">always aligned section on 16 bytes boundary.<br class=""><br class="">Added:<br class="">    llvm/trunk/test/Object/yaml2obj-elf-alignment.yaml<br class="">Modified:<br class="">    llvm/trunk/tools/yaml2obj/yaml2elf.cpp<br class=""><br class="">Added: llvm/trunk/test/Object/yaml2obj-elf-alignment.yaml<br class="">URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_test_Object_yaml2obj-2Delf-2Dalignment.yaml-3Frev-3D241674-26view-3Dauto&d=AwMFAg&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=YDLAtmcVe58ifmG8qRc-1GBwK4OOtXAkMbknBw-s3BY&s=Bln8v3UgQb6WJoE36dDs5thCrxNE-GHOaEW8KwqPQGk&e=" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/yaml2obj-elf-alignment.yaml?rev=241674&view=auto</a><br class="">==============================================================================<br class="">--- llvm/trunk/test/Object/yaml2obj-elf-alignment.yaml (added)<br class="">+++ llvm/trunk/test/Object/yaml2obj-elf-alignment.yaml Wed Jul  8 05:12:40 2015<br class="">@@ -0,0 +1,53 @@<br class="">+# Check that yaml2obj takes in account section AddressAlign field.<br class="">+<br class="">+# RUN: yaml2obj -format=elf %s > %t<br class="">+# RUN: llvm-readobj -s %t | FileCheck %s<br class="">+<br class="">+# CHECK:      Section {<br class="">+# CHECK:        Index: 2<br class="">+# CHECK-NEXT:   Name: .data<br class="">+# CHECK-NEXT:   Type: SHT_PROGBITS<br class="">+# CHECK-NEXT:   Flags [<br class="">+# CHECK-NEXT:     SHF_ALLOC<br class="">+# CHECK-NEXT:     SHF_WRITE<br class="">+# CHECK-NEXT:   ]<br class="">+# CHECK-NEXT:   Address: 0x0<br class="">+# CHECK-NEXT:   Offset: 0x{{[0-9A-F]*}}00<br class="">+# CHECK-NEXT:   Size: 4<br class="">+# CHECK-NEXT:   Link: 0<br class="">+# CHECK-NEXT:   Info: 0<br class="">+# CHECK-NEXT:   AddressAlignment: 256<br class="">+# CHECK-NEXT:   EntrySize: 0<br class="">+# CHECK-NEXT: }<br class="">+<br class="">+---<br class="">+FileHeader:<br class="">+  Class:    ELFCLASS32<br class="">+  Data:     ELFDATA2LSB<br class="">+  Type:     ET_REL<br class="">+  Machine:  EM_MIPS<br class="">+  Flags:    [ EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32 ]<br class="">+<br class="">+Sections:<br class="">+  - Name:          .text<br class="">+    Type:          SHT_PROGBITS<br class="">+    Flags:         [ SHF_ALLOC, SHF_EXECINSTR ]<br class="">+    AddressAlign:  8<br class="">+    Size:          4<br class="">+  - Name:          .data<br class="">+    Type:          SHT_PROGBITS<br class="">+    Flags:         [ SHF_WRITE, SHF_ALLOC ]<br class="">+    AddressAlign:  256<br class="">+    Size:          4<br class="">+<br class="">+Symbols:<br class="">+  Global:<br class="">+    - Name:     T0<br class="">+      Type:     STT_FUNC<br class="">+      Section:  .text<br class="">+      Size:     4<br class="">+    - Name:     D0<br class="">+      Type:     STT_OBJECT<br class="">+      Section:  .data<br class="">+      Size:     4<br class="">+...<br class=""><br class="">Modified: llvm/trunk/tools/yaml2obj/yaml2elf.cpp<br class="">URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_tools_yaml2obj_yaml2elf.cpp-3Frev-3D241674-26r1-3D241673-26r2-3D241674-26view-3Ddiff&d=AwMFAg&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=YDLAtmcVe58ifmG8qRc-1GBwK4OOtXAkMbknBw-s3BY&s=cxsBdfwY6kMDcJr_2bgnk6vSHptMgczwzI-e1PNSHHo&e=" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/yaml2obj/yaml2elf.cpp?rev=241674&r1=241673&r2=241674&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/tools/yaml2obj/yaml2elf.cpp (original)<br class="">+++ llvm/trunk/tools/yaml2obj/yaml2elf.cpp Wed Jul  8 05:12:40 2015<br class="">@@ -35,6 +35,8 @@ class ContiguousBlobAccumulator {<br class=""><br class="">   /// \returns The new offset.<br class="">   uint64_t padToAlignment(unsigned Align) {<br class="">+    if (Align == 0)<br class="">+      Align = 1;<br class="">     uint64_t CurrentOffset = InitialOffset + OS.tell();<br class="">     uint64_t AlignedOffset = RoundUpToAlignment(CurrentOffset, Align);<br class="">     for (; CurrentOffset != AlignedOffset; ++CurrentOffset)<br class="">@@ -46,7 +48,7 @@ public:<br class="">   ContiguousBlobAccumulator(uint64_t InitialOffset_)<br class="">       : InitialOffset(InitialOffset_), Buf(), OS(Buf) {}<br class="">   template <class Integer><br class="">-  raw_ostream &getOSAndAlignedOffset(Integer &Offset, unsigned Align = 16) {<br class="">+  raw_ostream &getOSAndAlignedOffset(Integer &Offset, unsigned Align) {<br class="">     Offset = padToAlignment(Align);<br class="">     return OS;<br class="">   }<br class="">@@ -246,7 +248,7 @@ bool ELFState<ELFT>::initSectionHeaders(<br class="">       SHeader.sh_size = S->Size;<br class="">       // SHT_NOBITS section does not have content<br class="">       // so just to setup the section offset.<br class="">-      CBA.getOSAndAlignedOffset(SHeader.sh_offset);<br class="">+      CBA.getOSAndAlignedOffset(SHeader.sh_offset, SHeader.sh_addralign);<br class="">     } else<br class="">       llvm_unreachable("Unknown section type");<br class=""><br class="">@@ -287,8 +289,9 @@ void ELFState<ELFT>::initSymtabSectionHe<br class="">   addSymbols(Doc.Symbols.Global, Syms, ELF::STB_GLOBAL);<br class="">   addSymbols(Doc.Symbols.Weak, Syms, ELF::STB_WEAK);<br class=""><br class="">-  writeArrayData(CBA.getOSAndAlignedOffset(SHeader.sh_offset),<br class="">-                 makeArrayRef(Syms));<br class="">+  writeArrayData(<br class="">+      CBA.getOSAndAlignedOffset(SHeader.sh_offset, SHeader.sh_addralign),<br class="">+      makeArrayRef(Syms));<br class="">   SHeader.sh_size = arrayDataSize(makeArrayRef(Syms));<br class=""> }<br class=""><br class="">@@ -299,7 +302,8 @@ void ELFState<ELFT>::initStrtabSectionHe<br class="">   zero(SHeader);<br class="">   SHeader.sh_name = DotShStrtab.getOffset(Name);<br class="">   SHeader.sh_type = ELF::SHT_STRTAB;<br class="">-  CBA.getOSAndAlignedOffset(SHeader.sh_offset) << STB.data();<br class="">+  CBA.getOSAndAlignedOffset(SHeader.sh_offset, SHeader.sh_addralign)<br class="">+      << STB.data();<br class="">   SHeader.sh_size = STB.data().size();<br class="">   SHeader.sh_addralign = 1;<br class=""> }<br class="">@@ -337,7 +341,8 @@ ELFState<ELFT>::writeSectionContent(Elf_<br class="">                                     ContiguousBlobAccumulator &CBA) {<br class="">   assert(Section.Size >= Section.Content.binary_size() &&<br class="">          "Section size and section content are inconsistent");<br class="">-  raw_ostream &OS = CBA.getOSAndAlignedOffset(SHeader.sh_offset);<br class="">+  raw_ostream &OS =<br class="">+      CBA.getOSAndAlignedOffset(SHeader.sh_offset, SHeader.sh_addralign);<br class="">   Section.Content.writeAsBinary(OS);<br class="">   for (auto i = Section.Content.binary_size(); i < Section.Size; ++i)<br class="">     OS.write(0);<br class="">@@ -364,7 +369,7 @@ ELFState<ELFT>::writeSectionContent(Elf_<br class="">   SHeader.sh_entsize = IsRela ? sizeof(Elf_Rela) : sizeof(Elf_Rel);<br class="">   SHeader.sh_size = SHeader.sh_entsize * Section.Relocations.size();<br class=""><br class="">-  auto &OS = CBA.getOSAndAlignedOffset(SHeader.sh_offset);<br class="">+  auto &OS = CBA.getOSAndAlignedOffset(SHeader.sh_offset, SHeader.sh_addralign);<br class=""><br class="">   for (const auto &Rel : Section.Relocations) {<br class="">     unsigned SymIdx = 0;<br class="">@@ -402,7 +407,7 @@ bool ELFState<ELFT>::writeSectionContent<br class="">   SHeader.sh_entsize = sizeof(Elf_Word);<br class="">   SHeader.sh_size = SHeader.sh_entsize * Section.Members.size();<br class=""><br class="">-  auto &OS = CBA.getOSAndAlignedOffset(SHeader.sh_offset);<br class="">+  auto &OS = CBA.getOSAndAlignedOffset(SHeader.sh_offset, SHeader.sh_addralign);<br class=""><br class="">   for (auto member : Section.Members) {<br class="">     Elf_Word SIdx;<br class="">@@ -433,7 +438,7 @@ bool ELFState<ELFT>::writeSectionContent<br class="">   SHeader.sh_entsize = sizeof(Flags);<br class="">   SHeader.sh_size = SHeader.sh_entsize;<br class=""><br class="">-  auto &OS = CBA.getOSAndAlignedOffset(SHeader.sh_offset);<br class="">+  auto &OS = CBA.getOSAndAlignedOffset(SHeader.sh_offset, SHeader.sh_addralign);<br class="">   Flags.version = Section.Version;<br class="">   Flags.isa_level = Section.ISALevel;<br class="">   Flags.isa_rev = Section.ISARevision;<br class=""><br class=""><br class="">_______________________________________________<br class="">llvm-commits mailing list<br class=""><a href="mailto:llvm-commits@cs.uiuc.edu" class="">llvm-commits@cs.uiuc.edu</a><br class="">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits<br class=""></div></div></blockquote></div><br class=""></body></html>