[PATCH] D44168: [ELF] Add .eh_frame pieces to map file

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 6 10:55:58 PST 2018


ruiu created this revision.
ruiu added reviewers: andrewng, rafael.
Herald added subscribers: arichardson, emaste.

This patch is a simplified version of https://reviews.llvm.org/D42960
written by Andrew Ng.


https://reviews.llvm.org/D44168

Files:
  lld/ELF/MapFile.cpp
  lld/ELF/SyntheticSections.h
  lld/test/ELF/Inputs/map-file2.s
  lld/test/ELF/map-file.s


Index: lld/test/ELF/map-file.s
===================================================================
--- lld/test/ELF/map-file.s
+++ lld/test/ELF/map-file.s
@@ -15,6 +15,8 @@
 
 .global _start
 _start:
+.cfi_startproc
+.cfi_endproc
  .quad sharedFoo
  .quad sharedBar
  .byte 0xe8
@@ -26,8 +28,8 @@
 .global _Z1fi
 _Z1fi:
 .cfi_startproc
-.cfi_endproc
 nop
+.cfi_endproc
 .weak bar
 bar:
 .long bar - .
@@ -51,8 +53,11 @@
 // CHECK-NEXT: 00000000002002d0 0000000000000030     8         <internal>:(.rela.dyn)
 // CHECK-NEXT: 0000000000200300 0000000000000030     8 .rela.plt
 // CHECK-NEXT: 0000000000200300 0000000000000030     8         <internal>:(.rela.plt)
-// CHECK-NEXT: 0000000000200330 0000000000000030     8 .eh_frame
-// CHECK-NEXT: 0000000000200330 0000000000000030     8         <internal>:(.eh_frame)
+// CHECK-NEXT: 0000000000200330 0000000000000060     8 .eh_frame
+// CHECK-NEXT: 0000000000200330 0000000000000018     0         {{.*}}{{/|\\}}map-file.s.tmp1.o:(.eh_frame+0x0)
+// CHECK-NEXT: 0000000000200348 0000000000000014     0         {{.*}}{{/|\\}}map-file.s.tmp1.o:(.eh_frame+0x18)
+// CHECK-NEXT: 0000000000200360 0000000000000014     0         {{.*}}{{/|\\}}map-file.s.tmp1.o:(.eh_frame+0x2c)
+// CHECK-NEXT: 0000000000200378 0000000000000018     0         {{.*}}{{/|\\}}map-file.s.tmp2.o:(.eh_frame+0x18)
 // CHECK-NEXT: 0000000000201000 000000000000002d     4 .text
 // CHECK-NEXT: 0000000000201000 0000000000000028     4         {{.*}}{{/|\\}}map-file.s.tmp1.o:(.text)
 // CHECK-NEXT: 0000000000201000 0000000000000000     0                 _start
Index: lld/test/ELF/Inputs/map-file2.s
===================================================================
--- lld/test/ELF/Inputs/map-file2.s
+++ lld/test/ELF/Inputs/map-file2.s
@@ -1,5 +1,7 @@
 foo:
+.cfi_startproc
 nop
+.cfi_endproc
 .global bar
 bar:
 nop
Index: lld/ELF/SyntheticSections.h
===================================================================
--- lld/ELF/SyntheticSections.h
+++ lld/ELF/SyntheticSections.h
@@ -83,6 +83,7 @@
   };
 
   std::vector<FdeData> getFdeData() const;
+  ArrayRef<CieRecord *> getCieRecords() const { return CieRecords; }
 
 private:
   uint64_t Size = 0;
Index: lld/ELF/MapFile.cpp
===================================================================
--- lld/ELF/MapFile.cpp
+++ lld/ELF/MapFile.cpp
@@ -138,6 +138,21 @@
 
     // Dump symbols for each input section.
     for (InputSection *IS : getInputSections(OSec)) {
+      if (IS == InX::EhFrame) {
+        auto Print = [&](const EhSectionPiece *P) {
+          writeHeader(OS, OSec->Addr + P->OutputOff, P->Size, 0);
+          OS << indent(1) << toString(P->Sec->File) << ":(" << P->Sec->Name
+             << "+0x" << Twine::utohexstr(P->InputOff) + ")\n";
+        };
+
+        for (const CieRecord *Rec : InX::EhFrame->getCieRecords()) {
+          Print(Rec->Cie);
+          for (const EhSectionPiece *Fde : Rec->Fdes)
+            Print(Fde);
+        }
+        continue;
+      }
+
       writeHeader(OS, OSec->Addr + IS->OutSecOff, IS->getSize(), IS->Alignment);
       OS << indent(1) << toString(IS) << '\n';
       for (Symbol *Sym : SectionSyms[IS])


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44168.137238.patch
Type: text/x-patch
Size: 3143 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180306/31aa2129/attachment-0001.bin>


More information about the llvm-commits mailing list