<div dir="ltr">Yes, looks like there are unfortunately still operating systems out there that use .ctors/.dtors and we can't kill it yet.<div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 7, 2017 at 9:37 AM, 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">Rui Ueyama via Phabricator <<a href="mailto:reviews@reviews.llvm.org" target="_blank">reviews@reviews.llvm.org</a>> writes:<br>
<br>
> +template <class T> static void reverseCopy(uint8_t *To, ArrayRef<T> From) {<br>
> +  T *Buf = (T *)To;<br>
> +  for (const T &Data : llvm::reverse(From))<br>
> +    *Buf++ = Data;<br>
<br>
I think you have to use a memcpy to not break strict aliasing rules.<br>
<br>
> Index: lld/ELF/OutputSections.cpp<br>
> ==============================<wbr>==============================<wbr>=======<br>
> --- lld/ELF/OutputSections.cpp<br>
> +++ lld/ELF/OutputSections.cpp<br>
> @@ -493,66 +493,6 @@<br>
>    Flags |= SHF_INFO_LINK;<br>
>  }<br>
><br>
> -// Returns true if S matches /Filename.?\.o$/.<br>
> -static bool isCrtBeginEnd(StringRef S, StringRef Filename) {<br>
> -  if (!S.endswith(".o"))<br>
> -    return false;<br>
> -  S = S.drop_back(2);<br>
> -  if (S.endswith(Filename))<br>
> -    return true;<br>
> -  return !S.empty() && S.drop_back().endswith(Filenam<wbr>e);<br>
> -}<br>
> -<br>
> -static bool isCrtbegin(StringRef S) { return isCrtBeginEnd(S, "crtbegin"); }<br>
> -static bool isCrtend(StringRef S) { return isCrtBeginEnd(S, "crtend"); }<br>
<br>
You still need to consider these, no? You can probably map them to<br>
lowest and highest priority.<br>
<br>
Given that all BSDs have init_array implemented, I agree that this is a<br>
reasonable direction to go. That way when time comes to write a new<br>
linker a decade or two from now it can hopefully ignore .ctors.<br>
<br>
Cheers,<br>
Rafael<br>
</blockquote></div><br></div></div>