[PATCH] D47602: Correct aligment computation for shared object symbols

Han Shen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 5 13:56:38 PDT 2018


shenhan added a comment.

Re-write the getAlignment function, keep the original logic but with the 3 additional tests:

1. return 0 for symbols with absolute address
2. for symbols with zero st_value, return section alignment.
3. for symbols with zero st_value and whose section alignment does not exist, return 0



================
Comment at: ELF/Relocations.cpp:532-534
+  if (SS.Alignment == 0)
+    fatal("cannot create a copy relocation for symbol "
+          "with absolute address " + toString(SS));
----------------
pcc wrote:
> ruiu wrote:
> > shenhan wrote:
> > > ruiu wrote:
> > > > Can you really trigger this? Please always add a test when you add a new feature.
> > > No, from the discussion, this could never be triggered, otherwise this is a linker error.
> > > Replaced with assert.
> > We don't add use assert() that much in lld. Please just remove.
> It's possible to get here with something like (the somewhat contrived)
> ```
> .globl abs
> abs = 0
> .size abs, 1
> ```
> in a .so, I think. I was imagining that we'd change the `if (SymSize == 0)` above to be `if (SymSize == 0 || SS.Alignment == 0)`. That would cover this case as well as the huge alignment case.
Done. Also, rewrite the getAlignment function, so huge alignment is erred out in getAlignment. And absolute symbols will error out here.


https://reviews.llvm.org/D47602





More information about the llvm-commits mailing list