-
-
Notifications
You must be signed in to change notification settings - Fork 604
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new mechanism for function aliases - outside original source file
For a long time, adding an alias to a function required us to use the "weak_alias" macro in the *same* source file as the original function. This caused us to modify some Musl files we didn't want to modify. In this patch I add a new mechanism for creating an alias for functions without modifying their original file. The original symbol's address is only known at link time, not compile time, so we do this symbol copying via a linker script - we have a new file libc/aliases.ld with a simple list of symbol assignments. To demonstrate the easiness and useful of this feature, we drop one file which we had to change from musl - res_init.c - just because we wanted to add an alias to it. With the new aliases.ld - we no longer need to modify the original file. In followup patches we can move a lot of the aliases we added in other ways (weak_alias / alias in modified files, wrappers in libc/math/aliases.cc) to the new aliases.ld. Signed-off-by: Nadav Har'El <nyh@scylladb.com> Message-Id: <20200803231809.1432323-1-nyh@scylladb.com>
- Loading branch information
Showing
5 changed files
with
15 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* This file defines symbols as *aliases* to other symbols. The linker | ||
* statically-linking the OSv kernel will set the alias's address to be | ||
* the same one as the original symbol. | ||
* | ||
* This technique is more powerful than the C compiler's "alias(...)" | ||
* attribute - the compiler-only technique is only usable when the alias | ||
* and original symbol are defined in the same translation unit, because | ||
* it is the compiler - not the linker - who need to copy the symbol's | ||
* address. | ||
*/ | ||
|
||
__res_init = res_init; |
This file was deleted.
Oops, something went wrong.