Stable Archive on
 help / color / Atom feed
* [4.14 PATCH] lkdtm: support llvm-objcopy
@ 2019-08-12 21:17 Nick Desaulniers
  2019-08-13  6:09 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 2+ messages in thread
From: Nick Desaulniers @ 2019-08-12 21:17 UTC (permalink / raw)
  To: stable
  Cc: pcc, Nick Desaulniers, Nathan Chancellor, Alan Modra,
	Jordan Rupprect, Kees Cook, Greg Kroah-Hartman

commit e9e08a07385e08f1a7f85c5d1e345c21c9564963 upstream.

With CONFIG_LKDTM=y and make OBJCOPY=llvm-objcopy, llvm-objcopy errors:
llvm-objcopy: error: --set-section-flags=.text conflicts with

Rather than support setting flags then renaming sections vs renaming
then setting flags, it's simpler to just change both at the same time
via --rename-section. Adding the load flag is required for GNU objcopy
to mark .rodata Type as PROGBITS after the rename.

This can be verified with:
$ readelf -S drivers/misc/lkdtm/rodata_objcopy.o
Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 1] .rodata           PROGBITS         0000000000000000  00000040
       0000000000000004  0000000000000000   A       0     0     4

Which shows that .text is now renamed .rodata, the alloc flag A is set,
the type is PROGBITS, and the section is not flagged as writeable W.

Reported-by: Nathan Chancellor <>
Suggested-by: Alan Modra <>
Suggested-by: Jordan Rupprect <>
Suggested-by: Kees Cook <>
Acked-by: Kees Cook <>
Reviewed-by: Nathan Chancellor <>
Signed-off-by: Nick Desaulniers <>
Signed-off-by: Greg Kroah-Hartman <>
This backport is for 4.14.  It should allow us to use llvm-objcopy for
RELR relocations on arm64 in Android.

 drivers/misc/Makefile | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index ad0e64fdba34..76f6a4f628b3 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -69,8 +69,7 @@ KCOV_INSTRUMENT_lkdtm_rodata.o	:= n
 OBJCOPYFLAGS_lkdtm_rodata_objcopy.o := \
-			--set-section-flags .text=alloc,readonly \
-			--rename-section .text=.rodata
+	--rename-section .text=.rodata,alloc,readonly,load
 targets += lkdtm_rodata.o lkdtm_rodata_objcopy.o
 $(obj)/lkdtm_rodata_objcopy.o: $(obj)/lkdtm_rodata.o FORCE
 	$(call if_changed,objcopy)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-12 21:17 [4.14 PATCH] lkdtm: support llvm-objcopy Nick Desaulniers
2019-08-13  6:09 ` Greg Kroah-Hartman

Stable Archive on

Archives are clonable:
	git clone --mirror stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ \
	public-inbox-index stable

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone