mirror of
https://github.com/rui314/mold.git
synced 2024-11-14 07:18:42 +03:00
temporary
This commit is contained in:
parent
8b8b210f6d
commit
626a370de1
@ -22,6 +22,7 @@
|
||||
#include <cstdlib>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
|
||||
using llvm::ArrayRef;
|
||||
using llvm::ErrorOr;
|
||||
@ -173,6 +174,7 @@ public:
|
||||
StringRef archive_name;
|
||||
int priority;
|
||||
bool is_alive = false;
|
||||
std::unordered_set<ObjectFile *> liveness_edges;
|
||||
|
||||
private:
|
||||
MemoryBufferRef mb;
|
||||
|
@ -101,6 +101,8 @@ void ObjectFile::register_undefined_symbols() {
|
||||
|
||||
Symbol &sym = symbol_instances[i];
|
||||
symbols[i] = symbol_table.get(sym.name);
|
||||
if (symbols[i])
|
||||
liveness_edges.insert(symbols[i]->file);
|
||||
num_undefined++;
|
||||
}
|
||||
}
|
||||
|
19
main.cc
19
main.cc
@ -103,6 +103,15 @@ static std::vector<ObjectFile *> read_file(StringRef path) {
|
||||
|
||||
llvm::TimerGroup timers("all", "all");
|
||||
|
||||
static void mark_live(ObjectFile *file) {
|
||||
if (file->is_alive)
|
||||
return;
|
||||
|
||||
file->is_alive = true;
|
||||
for (ObjectFile *other : file->liveness_edges)
|
||||
mark_live(other);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
MyOptTable opt_table;
|
||||
InputArgList args = opt_table.parse(argc - 1, argv + 1);
|
||||
@ -182,10 +191,16 @@ int main(int argc, char **argv) {
|
||||
|
||||
register_timer.stopTimer();
|
||||
|
||||
// Liveness propagation
|
||||
for (ObjectFile *file : files)
|
||||
if (file->archive_name == "")
|
||||
mark_live(file);
|
||||
|
||||
// Remove archive members that weren't used by any other
|
||||
// object files.
|
||||
std::remove_if(files.begin(), files.end(),
|
||||
[](ObjectFile *file) { return !file->is_alive; });
|
||||
files.erase(std::remove_if(files.begin(), files.end(),
|
||||
[](ObjectFile *file) { return !file->is_alive; }),
|
||||
files.end());
|
||||
|
||||
// Create output sections
|
||||
std::vector<OutputSection *> output_sections;
|
||||
|
Loading…
Reference in New Issue
Block a user