<div dir="auto">Hi Ed,<div dir="auto"><br></div><div dir="auto">Could you please always include cfe-commits as a subscriber in you phab reviews?</div><div dir="auto"><br></div><div dir="auto">We would like to be aware of these changes in advance before they land.</div><div dir="auto"><br></div><div dir="auto">Thanks.</div><div dir="auto"><br></div><div dir="auto">/ Asiri</div><div dir="auto"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 7 Mar 2017 6:27 p.m., "Ed Schouten via cfe-commits" <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ed<br>
Date: Tue Mar  7 12:15:52 2017<br>
New Revision: 297174<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=297174&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=297174&view=rev</a><br>
Log:<br>
Improve readability and correctness of the OS specific libunwind bits.<br>
<br>
All of the access to __exidx_*, dl_iterate_phdr(), etc. is specific to<br>
the findUnwindSections() function. Right now all of the includes and<br>
declarations related to them are scattered throughout the source file.<br>
For example, for <link.h>, we have a full list of operating systems<br>
guarding the #include, even though the code that uses dl_iterate_phdr()<br>
miraculously doesn't use the same list.<br>
<br>
Change the code so that findUnwindSections() is preceded by a block of<br>
#ifdefs that share the same structure as the function itself. First<br>
comes all of the macOS specific bits, followed by bare-metal ARM,<br>
followed by ELF EHABI + DWARF.<br>
<br>
This actually allows us to build a copy of libunwind without any<br>
specific ifdefs for NetBSD, CloudABI, etc. It likely also unbreaks the<br>
build of libunwind on FreeBSD/armv6, though I can't confirm.<br>
<br>
Reviewed by:    compnerd<br>
Differential Revision:  <a href="https://reviews.llvm.org/D30696" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D30696</a><br>
<br>
Modified:<br>
    libunwind/trunk/src/<wbr>AddressSpace.hpp<br>
<br>
Modified: libunwind/trunk/src/<wbr>AddressSpace.hpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/AddressSpace.hpp?rev=297174&r1=297173&r2=297174&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libunwind/trunk/src/<wbr>AddressSpace.hpp?rev=297174&<wbr>r1=297173&r2=297174&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libunwind/trunk/src/<wbr>AddressSpace.hpp (original)<br>
+++ libunwind/trunk/src/<wbr>AddressSpace.hpp Tue Mar  7 12:15:52 2017<br>
@@ -34,32 +34,6 @@ namespace libunwind {<br>
 #include "dwarf2.h"<br>
 #include "Registers.hpp"<br>
<br>
-#if _LIBUNWIND_ARM_EHABI<br>
-#if defined(_LIBUNWIND_IS_<wbr>BAREMETAL)<br>
-// When statically linked on bare-metal, the symbols for the EH table are looked<br>
-// up without going through the dynamic loader.<br>
-extern char __exidx_start;<br>
-extern char __exidx_end;<br>
-#else<br>
-#include <link.h><br>
-#endif // !defined(_LIBUNWIND_IS_<wbr>BAREMETAL)<br>
-#endif // _LIBUNWIND_ARM_EHABI<br>
-<br>
-#if defined(__CloudABI__) || defined(__FreeBSD__) || defined(__Fuchsia__) ||  \<br>
-    defined(__linux__) || defined(__NetBSD__)<br>
-#if _LIBUNWIND_SUPPORT_DWARF_<wbr>UNWIND && _LIBUNWIND_SUPPORT_DWARF_INDEX<br>
-#include <link.h><br>
-// Macro for machine-independent access to the ELF program headers. This<br>
-// macro is not available on some systems (e.g., FreeBSD). On these<br>
-// systems the data structures are just called Elf_XXX. Define ElfW()<br>
-// locally.<br>
-#if !defined(ElfW)<br>
-#define ElfW(type) Elf_##type<br>
-#endif<br>
-#include "EHHeaderParser.hpp"<br>
-#endif<br>
-#endif<br>
-<br>
 namespace libunwind {<br>
<br>
 /// Used by findUnwindSections() to return info about needed sections.<br>
@@ -291,6 +265,7 @@ LocalAddressSpace::<wbr>getEncodedP(pint_t &a<br>
 }<br>
<br>
 #ifdef __APPLE__<br>
+<br>
   struct dyld_unwind_sections<br>
   {<br>
     const struct mach_header*   mh;<br>
@@ -336,6 +311,30 @@ LocalAddressSpace::<wbr>getEncodedP(pint_t &a<br>
       return true;<br>
     }<br>
   #endif<br>
+<br>
+#elif _LIBUNWIND_ARM_EHABI && defined(_LIBUNWIND_IS_<wbr>BAREMETAL)<br>
+<br>
+// When statically linked on bare-metal, the symbols for the EH table are looked<br>
+// up without going through the dynamic loader.<br>
+extern char __exidx_start;<br>
+extern char __exidx_end;<br>
+<br>
+#elif _LIBUNWIND_ARM_EHABI || _LIBUNWIND_SUPPORT_DWARF_<wbr>UNWIND<br>
+<br>
+// ELF-based systems may use dl_iterate_phdr() to access sections<br>
+// containing unwinding information. The ElfW() macro for pointer-size<br>
+// independent ELF header traversal is not provided by <link.h> on some<br>
+// systems (e.g., FreeBSD). On these systems the data structures are<br>
+// just called Elf_XXX. Define ElfW() locally.<br>
+#include <link.h><br>
+#if !defined(ElfW)<br>
+#define ElfW(type) Elf_##type<br>
+#endif<br>
+<br>
+#if _LIBUNWIND_SUPPORT_DWARF_<wbr>UNWIND<br>
+#include "EHHeaderParser.hpp"<br>
+#endif<br>
+<br>
 #endif<br>
<br>
 inline bool LocalAddressSpace::<wbr>findUnwindSections(pint_t targetAddr,<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div></div>