[PATCH] D35509: Covnert .[cd]tors to .{init,fini}_array using synthetic section.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 11 21:45:48 PST 2017


Yes, looks like there are unfortunately still operating systems out there
that use .ctors/.dtors and we can't kill it yet.

On Thu, Dec 7, 2017 at 9:37 AM, Rafael Avila de Espindola <
rafael.espindola at gmail.com> wrote:

> Rui Ueyama via Phabricator <reviews at reviews.llvm.org> writes:
>
> > +template <class T> static void reverseCopy(uint8_t *To, ArrayRef<T>
> From) {
> > +  T *Buf = (T *)To;
> > +  for (const T &Data : llvm::reverse(From))
> > +    *Buf++ = Data;
>
> I think you have to use a memcpy to not break strict aliasing rules.
>
> > Index: lld/ELF/OutputSections.cpp
> > ===================================================================
> > --- lld/ELF/OutputSections.cpp
> > +++ lld/ELF/OutputSections.cpp
> > @@ -493,66 +493,6 @@
> >    Flags |= SHF_INFO_LINK;
> >  }
> >
> > -// Returns true if S matches /Filename.?\.o$/.
> > -static bool isCrtBeginEnd(StringRef S, StringRef Filename) {
> > -  if (!S.endswith(".o"))
> > -    return false;
> > -  S = S.drop_back(2);
> > -  if (S.endswith(Filename))
> > -    return true;
> > -  return !S.empty() && S.drop_back().endswith(Filename);
> > -}
> > -
> > -static bool isCrtbegin(StringRef S) { return isCrtBeginEnd(S,
> "crtbegin"); }
> > -static bool isCrtend(StringRef S) { return isCrtBeginEnd(S, "crtend"); }
>
> You still need to consider these, no? You can probably map them to
> lowest and highest priority.
>
> Given that all BSDs have init_array implemented, I agree that this is a
> reasonable direction to go. That way when time comes to write a new
> linker a decade or two from now it can hopefully ignore .ctors.
>
> Cheers,
> Rafael
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171211/de6829ae/attachment.html>


More information about the llvm-commits mailing list