<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"><base href="x-msg://1741/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>+ // Honour the alignment requirement.</div><div>+ uint8_t *AlignedAddr = Addr;</div><div>+ unsigned AlignNeeded = Alignment - ((uintptr_t)Addr % Alignment);</div><div>+ if (AlignNeeded != Alignment)</div><div>+ AlignedAddr = Addr + AlignNeeded;</div><div><br></div><div>Why not just the following?</div><div>AlignedAddr = (uint8_t*)(((uintptr_t)Addr + Alignment - 1) / Alignment * Alignment);</div><div><br></div><div><div>On Oct 12, 2012, at 5:36 AM, Amara Emerson <<a href="mailto:amara.emerson@arm.com">amara.emerson@arm.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div lang="EN-GB" link="blue" vlink="purple" style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div class="WordSection1" style="page: WordSection1; "><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">Hi,<o:p></o:p></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p> </o:p></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">The allocateDataSection() function in the default lli memory manager does not properly align the memory address it receives from calloc in accordance with the caller’s requirements. This obviously creates problems as the data in the section assumes a certain alignment, causing segfaults on ARM.<o:p></o:p></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p> </o:p></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">Please review the attached patch.<o:p></o:p></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p> </o:p></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; ">Amara<o:p></o:p></div></div><span><lli-align-datasection.patch></span>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu" style="color: purple; text-decoration: underline; ">llvm-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" style="color: purple; text-decoration: underline; ">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br></div></blockquote></div><br></body></html>