@@ -641,11 +641,14 @@ Symbol *SymbolTable::addUndefined(StringRef name, InputFile *f,
641
641
bool overrideLazy) {
642
642
auto [s, wasInserted] = insert (name, f);
643
643
if (wasInserted || (s->isLazy () && overrideLazy)) {
644
+ log (" Adding undefined " + name + " from " + toString (f));
644
645
replaceSymbol<Undefined>(s, name);
645
646
return s;
646
647
}
647
- if (s->isLazy ())
648
+ if (s->isLazy ()) {
649
+ log (" Loading lazy " + name + " due to undefined in " + toString (f));
648
650
forceLazy (s);
651
+ }
649
652
return s;
650
653
}
651
654
@@ -695,6 +698,7 @@ void SymbolTable::addLazyArchive(ArchiveFile *f, const Archive::Symbol &sym) {
695
698
return ;
696
699
auto [s, wasInserted] = insert (name);
697
700
if (wasInserted) {
701
+ log (" Adding lazy archive symbol " + name + " from " + toString (f));
698
702
replaceSymbol<LazyArchive>(s, f, sym);
699
703
return ;
700
704
}
@@ -703,6 +707,7 @@ void SymbolTable::addLazyArchive(ArchiveFile *f, const Archive::Symbol &sym) {
703
707
s->pendingArchiveLoad )
704
708
return ;
705
709
s->pendingArchiveLoad = true ;
710
+ log (" Immediately loading lazy " + name + " from " + toString (f) + " as it was undefined before" );
706
711
f->addMember (sym);
707
712
}
708
713
@@ -712,6 +717,7 @@ void SymbolTable::addLazyObject(InputFile *f, StringRef n) {
712
717
return ;
713
718
auto [s, wasInserted] = insert (n, f);
714
719
if (wasInserted) {
720
+ log (" Adding lazy object symbol " + n + " from " + toString (f));
715
721
replaceSymbol<LazyObject>(s, f, n);
716
722
return ;
717
723
}
@@ -808,9 +814,10 @@ void SymbolTable::reportDuplicate(Symbol *existing, InputFile *newFile,
808
814
Symbol *SymbolTable::addAbsolute (StringRef n, COFFSymbolRef sym) {
809
815
auto [s, wasInserted] = insert (n, nullptr );
810
816
s->isUsedInRegularObj = true ;
811
- if (wasInserted || isa<Undefined>(s) || s->isLazy ())
817
+ if (wasInserted || isa<Undefined>(s) || s->isLazy ()) {
818
+ log (" Added absolute " + n);
812
819
replaceSymbol<DefinedAbsolute>(s, ctx, n, sym);
813
- else if (auto *da = dyn_cast<DefinedAbsolute>(s)) {
820
+ } else if (auto *da = dyn_cast<DefinedAbsolute>(s)) {
814
821
if (da->getVA () != sym.getValue ())
815
822
reportDuplicate (s, nullptr );
816
823
} else if (!isa<DefinedCOFF>(s))
@@ -821,9 +828,10 @@ Symbol *SymbolTable::addAbsolute(StringRef n, COFFSymbolRef sym) {
821
828
Symbol *SymbolTable::addAbsolute (StringRef n, uint64_t va) {
822
829
auto [s, wasInserted] = insert (n, nullptr );
823
830
s->isUsedInRegularObj = true ;
824
- if (wasInserted || isa<Undefined>(s) || s->isLazy ())
831
+ if (wasInserted || isa<Undefined>(s) || s->isLazy ()) {
832
+ log (" Added absolute " + n);
825
833
replaceSymbol<DefinedAbsolute>(s, ctx, n, va);
826
- else if (auto *da = dyn_cast<DefinedAbsolute>(s)) {
834
+ } else if (auto *da = dyn_cast<DefinedAbsolute>(s)) {
827
835
if (da->getVA () != va)
828
836
reportDuplicate (s, nullptr );
829
837
} else if (!isa<DefinedCOFF>(s))
@@ -834,9 +842,10 @@ Symbol *SymbolTable::addAbsolute(StringRef n, uint64_t va) {
834
842
Symbol *SymbolTable::addSynthetic (StringRef n, Chunk *c) {
835
843
auto [s, wasInserted] = insert (n, nullptr );
836
844
s->isUsedInRegularObj = true ;
837
- if (wasInserted || isa<Undefined>(s) || s->isLazy ())
845
+ if (wasInserted || isa<Undefined>(s) || s->isLazy ()) {
846
+ log (" Added synthetic " + n);
838
847
replaceSymbol<DefinedSynthetic>(s, n, c);
839
- else if (!isa<DefinedCOFF>(s))
848
+ } else if (!isa<DefinedCOFF>(s))
840
849
reportDuplicate (s, nullptr );
841
850
return s;
842
851
}
@@ -845,10 +854,11 @@ Symbol *SymbolTable::addRegular(InputFile *f, StringRef n,
845
854
const coff_symbol_generic *sym, SectionChunk *c,
846
855
uint32_t sectionOffset, bool isWeak) {
847
856
auto [s, wasInserted] = insert (n, f);
848
- if (wasInserted || !isa<DefinedRegular>(s) || s->isWeak )
857
+ if (wasInserted || !isa<DefinedRegular>(s) || s->isWeak ) {
858
+ log (" Added regular " + n + " from " + toString (f));
849
859
replaceSymbol<DefinedRegular>(s, f, n, /* IsCOMDAT*/ false ,
850
860
/* IsExternal*/ true , sym, c, isWeak);
851
- else if (!isWeak)
861
+ } else if (!isWeak)
852
862
reportDuplicate (s, f, c, sectionOffset);
853
863
return s;
854
864
}
@@ -858,6 +868,7 @@ SymbolTable::addComdat(InputFile *f, StringRef n,
858
868
const coff_symbol_generic *sym) {
859
869
auto [s, wasInserted] = insert (n, f);
860
870
if (wasInserted || !isa<DefinedRegular>(s)) {
871
+ log (" Added comdat " + n + " from " + toString (f));
861
872
replaceSymbol<DefinedRegular>(s, f, n, /* IsCOMDAT*/ true ,
862
873
/* IsExternal*/ true , sym, nullptr );
863
874
return {cast<DefinedRegular>(s), true };
@@ -871,9 +882,10 @@ SymbolTable::addComdat(InputFile *f, StringRef n,
871
882
Symbol *SymbolTable::addCommon (InputFile *f, StringRef n, uint64_t size,
872
883
const coff_symbol_generic *sym, CommonChunk *c) {
873
884
auto [s, wasInserted] = insert (n, f);
874
- if (wasInserted || !isa<DefinedCOFF>(s))
885
+ if (wasInserted || !isa<DefinedCOFF>(s)) {
886
+ log (" Added common " + n + " from " + toString (f));
875
887
replaceSymbol<DefinedCommon>(s, f, n, size, sym, c);
876
- else if (auto *dc = dyn_cast<DefinedCommon>(s))
888
+ } else if (auto *dc = dyn_cast<DefinedCommon>(s))
877
889
if (size > dc->getSize ())
878
890
replaceSymbol<DefinedCommon>(s, f, n, size, sym, c);
879
891
return s;
@@ -884,6 +896,7 @@ DefinedImportData *SymbolTable::addImportData(StringRef n, ImportFile *f,
884
896
auto [s, wasInserted] = insert (n, nullptr );
885
897
s->isUsedInRegularObj = true ;
886
898
if (wasInserted || isa<Undefined>(s) || s->isLazy ()) {
899
+ log (" Added import data " + n + " from " + toString (f));
887
900
replaceSymbol<DefinedImportData>(s, n, f, location);
888
901
return cast<DefinedImportData>(s);
889
902
}
@@ -897,6 +910,7 @@ Defined *SymbolTable::addImportThunk(StringRef name, DefinedImportData *id,
897
910
auto [s, wasInserted] = insert (name, nullptr );
898
911
s->isUsedInRegularObj = true ;
899
912
if (wasInserted || isa<Undefined>(s) || s->isLazy ()) {
913
+ log (" Added import thunk " + name + " from " + toString (id->file ));
900
914
replaceSymbol<DefinedImportThunk>(s, ctx, name, id, chunk);
901
915
return cast<Defined>(s);
902
916
}
0 commit comments