@@ -44,7 +44,7 @@ using namespace lld::elf;
4444namespace {
4545template <class ELFT > class MarkLive {
4646public:
47- MarkLive (unsigned partition) : partition(partition) {}
47+ MarkLive (Ctx &ctx, unsigned partition) : ctx(ctx), partition(partition) {}
4848
4949 void run ();
5050 void moveToMain ();
@@ -60,6 +60,7 @@ template <class ELFT> class MarkLive {
6060 template <class RelTy >
6161 void scanEhFrameSection (EhInputSection &eh, ArrayRef<RelTy> rels);
6262
63+ Ctx &ctx;
6364 // The index of the partition that we are currently processing.
6465 unsigned partition;
6566
@@ -73,21 +74,21 @@ template <class ELFT> class MarkLive {
7374} // namespace
7475
7576template <class ELFT >
76- static uint64_t getAddend (InputSectionBase &sec,
77+ static uint64_t getAddend (Ctx &ctx, InputSectionBase &sec,
7778 const typename ELFT::Rel &rel) {
7879 return ctx.target ->getImplicitAddend (sec.content ().begin () + rel.r_offset ,
7980 rel.getType (ctx.arg .isMips64EL ));
8081}
8182
8283template <class ELFT >
83- static uint64_t getAddend (InputSectionBase &sec,
84+ static uint64_t getAddend (Ctx &, InputSectionBase &sec,
8485 const typename ELFT::Rela &rel) {
8586 return rel.r_addend ;
8687}
8788
8889// Currently, we assume all input CREL relocations have an explicit addend.
8990template <class ELFT >
90- static uint64_t getAddend (InputSectionBase &sec,
91+ static uint64_t getAddend (Ctx &, InputSectionBase &sec,
9192 const typename ELFT::Crel &rel) {
9293 return rel.r_addend ;
9394}
@@ -107,7 +108,7 @@ void MarkLive<ELFT>::resolveReloc(InputSectionBase &sec, RelTy &rel,
107108
108109 uint64_t offset = d->value ;
109110 if (d->isSection ())
110- offset += getAddend<ELFT>(sec, rel);
111+ offset += getAddend<ELFT>(ctx, sec, rel);
111112
112113 // fromFDE being true means this is referenced by a FDE in a .eh_frame
113114 // piece. The relocation points to the described function or to a LSDA. We
@@ -361,7 +362,7 @@ template <class ELFT> void MarkLive<ELFT>::moveToMain() {
361362// Before calling this function, Live bits are off for all
362363// input sections. This function make some or all of them on
363364// so that they are emitted to the output file.
364- template <class ELFT > void elf::markLive () {
365+ template <class ELFT > void elf::markLive (Ctx &ctx ) {
365366 llvm::TimeTraceScope timeScope (" markLive" );
366367 // If --gc-sections is not given, retain all input sections.
367368 if (!ctx.arg .gcSections ) {
@@ -378,13 +379,13 @@ template <class ELFT> void elf::markLive() {
378379
379380 // Follow the graph to mark all live sections.
380381 for (unsigned i = 1 , e = ctx.partitions .size (); i <= e; ++i)
381- MarkLive<ELFT>(i).run ();
382+ MarkLive<ELFT>(ctx, i).run ();
382383
383384 // If we have multiple partitions, some sections need to live in the main
384385 // partition even if they were allocated to a loadable partition. Move them
385386 // there now.
386387 if (ctx.partitions .size () != 1 )
387- MarkLive<ELFT>(1 ).moveToMain ();
388+ MarkLive<ELFT>(ctx, 1 ).moveToMain ();
388389
389390 // Report garbage-collected sections.
390391 if (ctx.arg .printGcSections )
@@ -393,7 +394,7 @@ template <class ELFT> void elf::markLive() {
393394 message (" removing unused section " + toString (sec));
394395}
395396
396- template void elf::markLive<ELF32LE>();
397- template void elf::markLive<ELF32BE>();
398- template void elf::markLive<ELF64LE>();
399- template void elf::markLive<ELF64BE>();
397+ template void elf::markLive<ELF32LE>(Ctx & );
398+ template void elf::markLive<ELF32BE>(Ctx & );
399+ template void elf::markLive<ELF64LE>(Ctx & );
400+ template void elf::markLive<ELF64BE>(Ctx & );
0 commit comments