@@ -553,22 +553,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
553
553
// values such as a default image base address.
554
554
target = getTarget ();
555
555
556
- switch (config->ekind ) {
557
- case ELF32LEKind:
558
- link<ELF32LE>(args);
559
- break ;
560
- case ELF32BEKind:
561
- link<ELF32BE>(args);
562
- break ;
563
- case ELF64LEKind:
564
- link<ELF64LE>(args);
565
- break ;
566
- case ELF64BEKind:
567
- link<ELF64BE>(args);
568
- break ;
569
- default :
570
- llvm_unreachable (" unknown Config->EKind" );
571
- }
556
+ link (args);
572
557
}
573
558
574
559
if (config->timeTraceEnabled ) {
@@ -2231,7 +2216,7 @@ static uint32_t getAndFeatures() {
2231
2216
2232
2217
// Do actual linking. Note that when this function is called,
2233
2218
// all linker scripts have already been parsed.
2234
- template < class ELFT > void LinkerDriver::link (opt::InputArgList &args) {
2219
+ void LinkerDriver::link (opt::InputArgList &args) {
2235
2220
llvm::TimeTraceScope timeScope (" Link" , StringRef (" LinkerDriver::Link" ));
2236
2221
// If a --hash-style option was not given, set to a default value,
2237
2222
// which varies depending on the target.
@@ -2399,7 +2384,7 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
2399
2384
//
2400
2385
// With this the symbol table should be complete. After this, no new names
2401
2386
// except a few linker-synthesized ones will be added to the symbol table.
2402
- compileBitcodeFiles<ELFT>( skipLinkedOutput);
2387
+ invokeELFT (compileBitcodeFiles, skipLinkedOutput);
2403
2388
2404
2389
// Symbol resolution finished. Report backward reference problems.
2405
2390
reportBackrefs ();
@@ -2440,7 +2425,7 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
2440
2425
llvm::TimeTraceScope timeScope (" Strip sections" );
2441
2426
llvm::erase_if (inputSections, [](InputSectionBase *s) {
2442
2427
if (s->type == SHT_LLVM_SYMPART) {
2443
- readSymbolPartitionSection<ELFT>( s);
2428
+ invokeELFT (readSymbolPartitionSection, s);
2444
2429
return true ;
2445
2430
}
2446
2431
@@ -2507,10 +2492,10 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
2507
2492
inputSections.push_back (createCommentSection ());
2508
2493
2509
2494
// Split SHF_MERGE and .eh_frame sections into pieces in preparation for garbage collection.
2510
- splitSections<ELFT>( );
2495
+ invokeELFT (splitSections );
2511
2496
2512
2497
// Garbage collection and removal of shared symbols from unused shared objects.
2513
- markLive<ELFT>( );
2498
+ invokeELFT (markLive );
2514
2499
demoteSharedSymbols ();
2515
2500
2516
2501
// Make copies of any input sections that need to be copied into each
@@ -2519,7 +2504,7 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
2519
2504
2520
2505
// Create synthesized sections such as .got and .plt. This is called before
2521
2506
// processSectionCommands() so that they can be placed by SECTIONS commands.
2522
- createSyntheticSections<ELFT>( );
2507
+ invokeELFT (createSyntheticSections );
2523
2508
2524
2509
// Some input sections that are used for exception handling need to be moved
2525
2510
// into synthetic sections. Do that now so that they aren't assigned to
@@ -2558,18 +2543,18 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
2558
2543
// Two input sections with different output sections should not be folded.
2559
2544
// ICF runs after processSectionCommands() so that we know the output sections.
2560
2545
if (config->icf != ICFLevel::None) {
2561
- findKeepUniqueSections<ELFT>( args);
2562
- doIcf<ELFT>( );
2546
+ invokeELFT (findKeepUniqueSections, args);
2547
+ invokeELFT (doIcf );
2563
2548
}
2564
2549
2565
2550
// Read the callgraph now that we know what was gced or icfed
2566
2551
if (config->callGraphProfileSort ) {
2567
2552
if (auto *arg = args.getLastArg (OPT_call_graph_ordering_file))
2568
2553
if (Optional<MemoryBufferRef> buffer = readFile (arg->getValue ()))
2569
2554
readCallGraph (*buffer);
2570
- readCallGraphsFromObjectFiles<ELFT>( );
2555
+ invokeELFT (readCallGraphsFromObjectFiles );
2571
2556
}
2572
2557
2573
2558
// Write the result to the file.
2574
- writeResult<ELFT>( );
2559
+ invokeELFT (writeResult );
2575
2560
}
0 commit comments