From: Nathan Chancellor <natechancellor@gmail.com>
To: Nick Desaulniers <ndesaulniers@google.com>
Cc: keescook@chromium.org, clang-built-linux@googlegroups.com,
Nathan Chancellor <nathanchance@gmail.com>,
Jordan Rupprect <rupprecht@google.com>,
Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] lkdtm: support llvm-objcopy
Date: Mon, 13 May 2019 16:29:10 -0700 [thread overview]
Message-ID: <20190513232910.GA30209@archlinux-i9> (raw)
In-Reply-To: <20190513222109.110020-1-ndesaulniers@google.com>
On Mon, May 13, 2019 at 03:21:09PM -0700, 'Nick Desaulniers' via Clang Built Linux wrote:
> With CONFIG_LKDTM=y and make OBJCOPY=llvm-objcopy, llvm-objcopy errors:
> llvm-objcopy: error: --set-section-flags=.text conflicts with
> --rename-section=.text=.rodata
>
> 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.
>
> 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 in the Flags field that .text is now renamed .rodata, the
> append flag A is set, and the section is not flagged as writeable W.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/448
> Reported-by: Nathan Chancellor <nathanchance@gmail.com>
This should be natechancellor@gmail.com (although I think I do own that
email, just haven't been into it for 10+ years...)
> Suggested-by: Jordan Rupprect <rupprecht@google.com>
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
> drivers/misc/lkdtm/Makefile | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/misc/lkdtm/Makefile b/drivers/misc/lkdtm/Makefile
> index 951c984de61a..89dee2a9d88c 100644
> --- a/drivers/misc/lkdtm/Makefile
> +++ b/drivers/misc/lkdtm/Makefile
> @@ -15,8 +15,7 @@ KCOV_INSTRUMENT_rodata.o := n
>
> OBJCOPYFLAGS :=
> OBJCOPYFLAGS_rodata_objcopy.o := \
> - --set-section-flags .text=alloc,readonly \
> - --rename-section .text=.rodata
> + --rename-section .text=.rodata,alloc,readonly
> targets += rodata.o rodata_objcopy.o
> $(obj)/rodata_objcopy.o: $(obj)/rodata.o FORCE
> $(call if_changed,objcopy)
> --
> 2.21.0.1020.gf2820cf01a-goog
>
I ran this script to see if there was any change for GNU objcopy and it
looks like .rodata's type gets changed, is this intentional? Otherwise,
this works for llvm-objcopy like you show.
-----------
1c1
< There are 11 section headers, starting at offset 0x240:
---
> There are 11 section headers, starting at offset 0x230:
8c8
< [ 1] .rodata PROGBITS 0000000000000000 00000040
---
> [ 1] .rodata NOBITS 0000000000000000 00000040
10c10
-----------
#!/bin/bash
TMP1=$(mktemp)
TMP2=$(mktemp)
git checkout next-20190513
make -j$(nproc) ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- O=out mrproper allyesconfig drivers/misc/lkdtm/
readelf -S out/drivers/misc/lkdtm/rodata_objcopy.o > ${TMP1}
curl -LSs https://lore.kernel.org/lkml/20190513222109.110020-1-ndesaulniers@google.com/raw | git am -3
make -j$(nproc) ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- O=out mrproper allyesconfig drivers/misc/lkdtm/
readelf -S out/drivers/misc/lkdtm/rodata_objcopy.o > ${TMP2}
diff ${TMP1} ${TMP2}
next prev parent reply other threads:[~2019-05-13 23:29 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-13 22:21 [PATCH] lkdtm: support llvm-objcopy Nick Desaulniers
2019-05-13 22:26 ` Nick Desaulniers
2019-05-13 23:04 ` Kees Cook
2019-05-13 23:29 ` Nathan Chancellor [this message]
2019-05-13 23:38 ` Jordan Rupprecht
2019-05-13 23:47 ` Nathan Chancellor
2019-05-13 23:50 ` Nick Desaulniers
2019-05-14 18:10 ` Kees Cook
2019-05-14 20:24 ` Nick Desaulniers
2019-05-15 16:42 ` Kees Cook
2019-05-15 17:37 ` Nick Desaulniers
2019-05-15 18:12 ` [PATCH v2] " Nick Desaulniers
2019-05-15 18:19 ` Nathan Chancellor
2019-05-15 18:24 ` [PATCH v3] " Nick Desaulniers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190513232910.GA30209@archlinux-i9 \
--to=natechancellor@gmail.com \
--cc=arnd@arndb.de \
--cc=clang-built-linux@googlegroups.com \
--cc=gregkh@linuxfoundation.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nathanchance@gmail.com \
--cc=ndesaulniers@google.com \
--cc=rupprecht@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox