<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 7, 2015 at 4:09 PM, Davide Italiano via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Fri, Sep 4, 2015 at 10:01 PM, Michael Spencer <<a href="mailto:bigcheesegs@gmail.com">bigcheesegs@gmail.com</a>> wrote:<br>
> On Fri, Sep 4, 2015 at 5:48 PM, Davide Italiano <<a href="mailto:davide@freebsd.org">davide@freebsd.org</a>> wrote:<br>
>> On Fri, Sep 4, 2015 at 5:25 PM, Michael J. Spencer via llvm-commits<br>
>> <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br>
>>> Author: mspencer<br>
>>> Date: Fri Sep  4 19:25:33 2015<br>
>>> New Revision: 246901<br>
>>><br>
>>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=246901&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=246901&view=rev</a><br>
>>> Log:<br>
>>> [elf2] Correctly handle sections with an alignment of 0. Spec says to treat it as an alignment of 1.<br>
>>><br>
>>> Added: lld/trunk/test/elf2/section-align-0.test<br>
>>> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/section-align-0.test?rev=246901&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/section-align-0.test?rev=246901&view=auto</a><br>
>>> ==============================================================================<br>
>>> --- lld/trunk/test/elf2/section-align-0.test (added)<br>
>>> +++ lld/trunk/test/elf2/section-align-0.test Fri Sep  4 19:25:33 2015<br>
>>> @@ -0,0 +1,19 @@<br>
>>> +# RUN: yaml2obj -format elf %s -o %t<br>
>>> +# RUN: lld -flavor gnu2 %t -o %tout<br>
>>> +<br>
>><br>
>> Is there any reason why you can't use assembler for testing?<br>
><br>
> Feel free to change it if you know the magic incantation necessary to<br>
> get llvm-mc to emit an alignment of 0.<br>
><br>
> - Michael Spencer<br>
><br>
>><br>
<br>
</span>I spent some time analyzing this -- and I noticed your commit<br>
indirectly exposes a couple of problems in llvm-mc:<br>
<br>
1) .align directive refuses alignment 0 -- a comment in the code hints<br>
this is done for GNU as compatibility, but it seems GNU as accepts<br>
.align 0 (and silently rounds up alignment to 1). I have a patch to<br>
fix that that I'll submit shortly .<br>
<br>
$ ./llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu blah.s -o blah<br>
blah.s:4:8: error: alignment must be a power of 2<br>
.align 0<br>
       ^<br>
$ as blah.s -o blah<br>
$<br>
<br>
$ cat blah.s<br>
.global _start<br>
.global bar<br>
<br>
.align 0<br>
.text<br>
_start:<br>
bar:<br>
  movl $bar, %edx<br>
<br>
2) If we change align to 1 -- it seems llvm-mc doesn't honor it, but<br>
silently rounds up that to 4. Not sure if this is a bug or intended<br>
behavior. CC:ing Rafael as he did most of the recent work on ELF MC.<br>
<br>
[llvm-mc]<br>
<br>
$ readelf -S blah<br>
  [ 2] .text             PROGBITS         0000000000000000  00000040<br>
       0000000000000005  0000000000000000  AX       0     0     4<br>
<br>
[GNU as]<br>
<br>
$ readelf -S blah<br>
  [ 1] .text             PROGBITS         0000000000000000  00000040<br>
       0000000000000005  0000000000000000  AX       0     0     1<br>
<br>
About your testcase -- I'm not sure if there's a way to emit a section<br>
with alignment zero as also GNU as seems to round up that to 1<br>
silently. I want to think a little bit harder about it, if somebody<br>
has ideas on how to handle, they're welcome.<br></blockquote><div><br></div><div>Couldn't a readable testcase be crafted with yaml2obj?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Thanks,<br>
<div class="HOEnZb"><div class="h5"><br>
--<br>
Davide<br>
<br>
"There are no solved problems; there are only problems that are more<br>
or less solved" -- Henri Poincare<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div></div>