mirror of
https://github.com/rui314/mold.git
synced 2024-11-11 05:46:58 +03:00
[Mach-O] wip
This commit is contained in:
parent
834d0045ae
commit
d599ebe3b9
@ -179,6 +179,12 @@ int main(int argc, char **argv) {
|
||||
|
||||
read_input_files(ctx, file_args);
|
||||
|
||||
i64 priority = 1;
|
||||
for (ObjectFile *obj : ctx.objs)
|
||||
obj->priority = priority++;
|
||||
for (DylibFile *dylib : ctx.dylibs)
|
||||
dylib->priority = priority++;
|
||||
|
||||
for (ObjectFile *obj : ctx.objs)
|
||||
obj->parse(ctx);
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <tbb/concurrent_hash_map.h>
|
||||
#include <tbb/spin_mutex.h>
|
||||
#include <unordered_map>
|
||||
#include <variant>
|
||||
|
||||
@ -51,6 +52,7 @@ class InputFile {
|
||||
public:
|
||||
MappedFile<Context> *mf = nullptr;
|
||||
std::vector<Symbol *> syms;
|
||||
i64 priority = 0;
|
||||
|
||||
protected:
|
||||
InputFile() = default;
|
||||
@ -141,10 +143,11 @@ struct Symbol {
|
||||
|
||||
std::string_view name;
|
||||
|
||||
ObjectFile *file = nullptr;
|
||||
InputFile *file = nullptr;
|
||||
Subsection *subsec = nullptr;
|
||||
u64 value = 0;
|
||||
i32 stub_idx = -1;
|
||||
tbb::spin_mutex mu;
|
||||
|
||||
inline u64 get_addr(Context &ctx) const;
|
||||
};
|
||||
|
@ -157,6 +157,10 @@ void ObjectFile::resolve_symbols(Context &ctx) {
|
||||
Symbol &sym = *syms[i];
|
||||
MachSym &msym = mach_syms[i];
|
||||
|
||||
std::lock_guard lock(sym.mu);
|
||||
if (sym.file && sym.file->priority < priority)
|
||||
continue;
|
||||
|
||||
switch (msym.type) {
|
||||
case N_ABS:
|
||||
sym.file = this;
|
||||
@ -194,4 +198,13 @@ void DylibFile::parse(Context &ctx) {
|
||||
}
|
||||
}
|
||||
|
||||
void DylibFile::resolve_symbols(Context &ctx) {
|
||||
for (Symbol *sym : syms) {
|
||||
std::lock_guard lock(sym->mu);
|
||||
if (sym->file && sym->file->priority < priority)
|
||||
continue;
|
||||
sym->file = this;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mold::macho
|
||||
|
Loading…
Reference in New Issue
Block a user