<div dir="ltr"><div>Somewhat orthogonal to the original issue, but if object files are aligned only to two bytes in a static archive, and if we are using the four byte aligned load instruction on armv6 to load data from object files, that means current LLVM can easily cause a bus error on armv6, no?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 5, 2017 at 6:22 PM, Rafael Avila de Espindola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">Rui Ueyama <<a href="mailto:ruiu@google.com">ruiu@google.com</a>> writes:<br>
<br>
> On Tue, Dec 5, 2017 at 1:22 PM, Rafael Avila de Espindola <<br>
> <a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>> wrote:<br>
><br>
>> Martin Richtarsky <<a href="mailto:s@martinien.de">s@martinien.de</a>> writes:<br>
>><br>
>> > Output looks as follows [1] Seems sh_offset is missing?<br>
>><br>
>> That is what readelf prints as Off<br>
>><br>
>> >   [17] .rela.text        RELA            0000000000000000 071423 001728<br>
>> 18<br>
>> >      1   4  8<br>
>><br>
>> The offset of rela text should have been aligned, but it is not. Can you<br>
>> report a bug on icc? As a work around using the gnu assembler if<br>
>> possible should fix this.<br>
><br>
><br>
> Yeah this is a violation of the spec and must be a bug in ICC. That being<br>
> said, is there a practical benefit of checking the validity of the<br>
> alignment, except finding buggy object files early? I mean, if an object<br>
> file is in an static archive, all "aligned" data in the object file might<br>
> not be aligned against the beginning of the archive file.<br>
<br>
</div></div>It will at least be aligned to two bytes.<br>
<br>
With most current host architectures handling<br>
packed_endian_specific_<wbr>integral is fairly efficient. For example, on<br>
x86_64 reading 32 bits with 1 2 and 4 byte alignment produces in all<br>
cases:<br>
<br>
  movl    (%rdi), %eax<br>
<br>
But on armv6 the aligned case is<br>
<br>
  ldr     r0, [r0]<br>
<br>
the 2 byte aligned case is<br>
<br>
  ldrh    r1, [r0, #2]<br>
  ldrh    r0, [r0]<br>
  orr     r0, r0, r1, lsl #16<br>
<br>
and the unaligned case is<br>
<br>
  ldrb    r1, [r0]<br>
  ldrb    r2, [r0, #1]<br>
  ldrb    r3, [r0, #2]<br>
  ldrb    r0, [r0, #3]<br>
  orr     r1, r1, r2, lsl #8<br>
  orr     r0, r3, r0, lsl #8<br>
  orr     r0, r1, r0, lsl #16<br>
<br>
On armv7 it is a single ldr on all cases.<br>
<br>
Now, I don't really know how much we support *host* architectures<br>
without a unaligned load instruction. If we don't care about making lld<br>
and other llvm tools slower on those host architectures we could use<br>
packed_endian_specific_<wbr>integral with an alignment of 1 and remove the<br>
check. I guess we have to ask on llvmdev before changing that.<br>
<br>
Cheers,<br>
Rafael<br>
</blockquote></div><br></div>