[PATCH] D39918: [libunwind] Remove a FIXME about truncated section names

Martin Storsjö via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 10 12:07:56 PST 2017


mstorsjo created this revision.
Herald added a subscriber: aprantl.

If the linker chose to store the full section name instead of truncating it, this field doesn't contain a truncated name, but an offset into the string table of the binary. The string table isn't loaded/mapped into memory during runtime though, so it's not possible to read the full section name, unless we try to locate the DLL/EXE on disk that the HMODULE corresponds to and load that manually.

This also has the practical consequence that with the current LLD, we must not enable debug info (i.e. must link with -s with the mingw frontend). If debug info is enabled, the full ".eh_frame" name is written into the string table and the the section name itself is just an offset, e.g. "/4".

Alternatives to fixing this consequence are:

- Making LLD always output a truncated ".eh_fram" (maybe only when -lldmingw is specified?), even if debug info is enabled. (GNU ld doesn't do this, so this approach in libunwind won't work with binaries built with that.)
- Switch to statically registering the .eh_frame sections on startup, instead of dynamically enumerating them when needed. This is what libgcc does. This doesn't match what libunwind does on other platforms though. This only works as long as libunwind is linked dynamically so that all involved DLLs register their sections to the same instance of libunwind. (I haven't succeeded in building a shared libcxx/libcxxabi/libunwind yet for mingw though.)


https://reviews.llvm.org/D39918

Files:
  src/AddressSpace.hpp


Index: src/AddressSpace.hpp
===================================================================
--- src/AddressSpace.hpp
+++ src/AddressSpace.hpp
@@ -382,8 +382,6 @@
           found_obj = true;
       } else if (!strncmp((const char *)pish->Name, ".eh_frame",
                           IMAGE_SIZEOF_SHORT_NAME)) {
-        // FIXME: This section name actually is truncated, ideally we
-        // should locate and check the full long name instead.
         info.dwarf_section = begin;
         info.dwarf_section_length = pish->Misc.VirtualSize;
         found_hdr = true;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39918.122498.patch
Type: text/x-patch
Size: 576 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171110/b6d13429/attachment.bin>


More information about the cfe-commits mailing list