[WebAssembly] Implement -print-gc-sections, to better test GC of globals
Differential Revision: https://reviews.llvm.org/D44311
llvm-svn: 330456
diff --git a/lld/wasm/MarkLive.cpp b/lld/wasm/MarkLive.cpp
index 2b30f6a..95d9782 100644
--- a/lld/wasm/MarkLive.cpp
+++ b/lld/wasm/MarkLive.cpp
@@ -22,6 +22,7 @@
#include "MarkLive.h"
#include "Config.h"
#include "InputChunks.h"
+#include "InputGlobal.h"
#include "SymbolTable.h"
#include "Symbols.h"
@@ -102,9 +103,15 @@
for (InputChunk *C : Obj->Segments)
if (!C->Live)
message("removing unused section " + toString(C));
+ for (InputGlobal *G : Obj->Globals)
+ if (!G->Live)
+ message("removing unused section " + toString(G));
}
for (InputChunk *C : Symtab->SyntheticFunctions)
if (!C->Live)
message("removing unused section " + toString(C));
+ for (InputGlobal *G : Symtab->SyntheticGlobals)
+ if (!G->Live)
+ message("removing unused section " + toString(G));
}
}