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