Skip to content

Commit

Permalink
Do not rewrite endbr64 of exported functions
Browse files Browse the repository at this point in the history
  • Loading branch information
rui314 committed Dec 12, 2023
1 parent a4daff2 commit 4db2eb9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion elf/passes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1587,6 +1587,12 @@ void rewrite_endbr(Context<E> &ctx) {
}
});

// Exported symbols are conservatively assumed to be address-taken.
if (ctx.dynsym)
for (Symbol<E> *sym : ctx.dynsym->symbols)
if (sym && sym->is_exported)
sym->address_taken = true;

// Some symbols are implicitly address-taken
ctx.arg.entry->address_taken = true;
ctx.arg.init->address_taken = true;
Expand Down Expand Up @@ -1956,7 +1962,7 @@ void compute_address_significance(Context<E> &ctx) {
// Exported symbols are conservatively considered address-taken.
if (ctx.dynsym)
for (Symbol<E> *sym : ctx.dynsym->symbols)
if (sym->is_exported)
if (sym && sym->is_exported)
mark(sym);

// Handle data objects.
Expand Down

0 comments on commit 4db2eb9

Please sign in to comment.