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;


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;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to