Skip to content

Commit

Permalink
objtool: Use R_*_NONE relocations for annotations
Browse files Browse the repository at this point in the history
.discard.retpoline_safe sections do not have the SHF_ALLOC flag.  These
sections referencing text sections with PC-relative relocations like
R_386_PC32 [0] are conceptually not suitable.  Newer LLD will report
warnings even for relocatable links [1].

    ld.lld: warning: vmlinux.a(drivers/i2c/busses/i2c-i801.o):(.discard.retpoline_safe+0x120): has non-ABS relocation R_386_PC32 against symbol ''

Since the annotation is RELA only (therefore i386 is unsupported), we
can utilitize R_*_NONE relocations for annotation, making
.discard.retpoline_safe sections zero-sized.  If we ever support i386
REL relocations, which requires teaching reloc_addend implicit addends,
we can utilitize .long directives just for REL.

[0]: commit 1c0c1fa ("objtool: Use relative pointers for
annotations")

Link: ClangBuiltLinux#1937 [1]
Signed-off-by: Fangrui Song <maskray@google.com>
  • Loading branch information
MaskRay committed Sep 19, 2023
1 parent 2cf0f71 commit c31642f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions arch/x86/include/asm/nospec-branch.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
.macro ANNOTATE_RETPOLINE_SAFE
.Lhere_\@:
.pushsection .discard.retpoline_safe
.long .Lhere_\@ - .
.reloc ., BFD_RELOC_NONE, .Lhere_\@
.popsection
.endm

Expand Down Expand Up @@ -334,7 +334,7 @@
#define ANNOTATE_RETPOLINE_SAFE \
"999:\n\t" \
".pushsection .discard.retpoline_safe\n\t" \
".long 999b - .\n\t" \
".reloc ., BFD_RELOC_NONE, 999b\n\t" \
".popsection\n\t"

typedef u8 retpoline_thunk_t[RETPOLINE_THUNK_SIZE];
Expand Down

0 comments on commit c31642f

Please sign in to comment.