File tree Expand file tree Collapse file tree 4 files changed +7
-11
lines changed Expand file tree Collapse file tree 4 files changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,7 @@ struct Config {
9393 // for shared libraries (since they always added to a dynamic offset at
9494 // runtime).
9595 uint64_t tableBase;
96+ uint64_t functionPointerAlignment;
9697 uint64_t zStackSize;
9798 unsigned ltoPartitions;
9899 unsigned ltoo;
Original file line number Diff line number Diff line change @@ -638,6 +638,7 @@ static void readConfigs(opt::InputArgList &args) {
638638 LLVM_DEBUG (errorHandler ().verbose = true );
639639
640640 config->tableBase = args::getInteger (args, OPT_table_base, 0 );
641+ config->functionPointerAlignment = args::getInteger (args, OPT_function_pointer_alignment, 0 );
641642 config->globalBase = args::getInteger (args, OPT_global_base, 0 );
642643 config->initialHeap = args::getInteger (args, OPT_initial_heap, 0 );
643644 config->initialMemory = args::getInteger (args, OPT_initial_memory, 0 );
Original file line number Diff line number Diff line change @@ -251,6 +251,9 @@ def stack_first: FF<"stack-first">,
251251def table_base: JJ<"table-base=">,
252252 HelpText<"Table offset at which to place address taken functions (Defaults to 1)">;
253253
254+ def function_pointer_alignment: JJ<"function-pointer-alignment=">,
255+ HelpText<"Align function pointers at a given value (Defaults to 1)">;
256+
254257defm whole_archive: B<"whole-archive",
255258 "Force load of all members in a static library",
256259 "Do not force load of all members in a static library (default)">;
Original file line number Diff line number Diff line change @@ -567,20 +567,11 @@ void ElemSection::addEntry(FunctionSymbol *sym) {
567567 if (sym->hasTableIndex () || sym->isStub )
568568 return ;
569569
570- uint32_t padding = 0 ;
571- uint64_t alignment = 1 ;
572-
573- if (indirectFunctions.size () == 0 && padding > 0 ) {
574- for (uint32_t i=0 ; i<padding; i++) {
575- indirectFunctions.push_back (nullptr );
576- }
577- }
578-
579570 sym->setTableIndex (config->tableBase + indirectFunctions.size ());
580571 indirectFunctions.emplace_back (sym);
581572
582- if (alignment > 1 ) {
583- for (uint32_t i=0 ; i<alignment -1 ; i++) {
573+ if (config-> functionPointerAlignment > 1 ) {
574+ for (uint32_t i=0 ; i<config-> functionPointerAlignment -1 ; i++) {
584575 indirectFunctions.push_back (nullptr );
585576 }
586577 }
You can’t perform that action at this time.
0 commit comments