objtool: Add relocation check for alternative sections
Relocations in alternative code can be dangerous, because the code is
copy/pasted to the text section after relocations have been resolved,
which can corrupt PC-relative addresses.
However, relocations might be acceptable in some cases, depending on the
architecture. For example, the x86 alternatives code manually fixes up
the target addresses for PC-relative jumps and calls.
So disallow relocations in alternative code, except where the x86 arch
code allows it.
This code may need to be tweaked for other arches when objtool gets
support for them.
Suggested-by: Linus Torvalds <firstname.lastname@example.org>
Signed-off-by: Josh Poimboeuf <email@example.com>
Signed-off-by: Borislav Petkov <firstname.lastname@example.org>
Reviewed-by: Julien Thierry <email@example.com>
1 file changed