summaryrefslogtreecommitdiff
authorSami Tolvanen <samitolvanen@google.com>2018-10-04 15:56:16 (GMT)
committer Sami Tolvanen <samitolvanen@google.com>2018-12-10 18:52:08 (GMT)
commit3cb8c941dfc0a8febe5e31bb4f94ddc0592ba4d7 (patch)
treeef4c10fb0a9f06439c81fa080a356b8a03040dae
parent0e70f1102d77685c5571ddbfd35ff9cb31d5fe00 (diff)
downloadcommon-3cb8c941dfc0a8febe5e31bb4f94ddc0592ba4d7.zip
common-3cb8c941dfc0a8febe5e31bb4f94ddc0592ba4d7.tar.gz
common-3cb8c941dfc0a8febe5e31bb4f94ddc0592ba4d7.tar.bz2
ANDROID: modpost: add an exception for CFI stubs
When CONFIG_CFI_CLANG is enabled, LLVM renames all address taken functions by appending a .cfi postfix to their names, and creates function stubs with the original names. The compiler always injects these stubs to the text section, even if the function itself is placed into init or exit sections, which creates modpost warnings. This commit adds a modpost exception for CFI stubs to prevent the warnings. Bug: 117237524 Change-Id: Ieb8bf20d0c3ad7b7295c535f598370220598cdb0 Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Diffstat
-rw-r--r--scripts/mod/modpost.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index fdf5bbf..e5c4114 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -936,6 +936,7 @@ static const char *const head_sections[] = { ".head.text*", NULL };
static const char *const linker_symbols[] =
{ "__init_begin", "_sinittext", "_einittext", NULL };
static const char *const optim_symbols[] = { "*.constprop.*", NULL };
+static const char *const cfi_symbols[] = { "*.cfi", NULL };
enum mismatch {
TEXT_TO_ANY_INIT,
@@ -1157,6 +1158,16 @@ static const struct sectioncheck *section_mismatch(
* fromsec = text section
* refsymname = *.constprop.*
*
+ * Pattern 6:
+ * With CONFIG_CFI_CLANG, clang appends .cfi to all indirectly called
+ * functions and creates a function stub with the original name. This
+ * stub is always placed in .text, even if the actual function with the
+ * .cfi postfix is in .init.text or .exit.text.
+ * This pattern is identified by
+ * tosec = init or exit section
+ * fromsec = text section
+ * tosym = *.cfi
+ *
**/
static int secref_whitelist(const struct sectioncheck *mismatch,
const char *fromsec, const char *fromsym,
@@ -1195,6 +1206,12 @@ static int secref_whitelist(const struct sectioncheck *mismatch,
match(fromsym, optim_symbols))
return 0;
+ /* Check for pattern 6 */
+ if (match(fromsec, text_sections) &&
+ match(tosec, init_exit_sections) &&
+ match(tosym, cfi_symbols))
+ return 0;
+
return 1;
}