lkml.org 
[lkml]   [2019]   [May]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] lkdtm: support llvm-objcopy
On Tue, May 14, 2019 at 01:24:37PM -0700, Nick Desaulniers wrote:
> On Tue, May 14, 2019 at 11:11 AM Kees Cook <keescook@chromium.org> wrote:
> >
> > On Mon, May 13, 2019 at 04:50:05PM -0700, Nick Desaulniers wrote:
> > > On Mon, May 13, 2019 at 4:29 PM Nathan Chancellor
> > > <natechancellor@gmail.com> wrote:
> > > >
> > > > 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.
>
> I'm not sure I want to call it a bug in the initial implementation. I've filed:
> https://sourceware.org/bugzilla/show_bug.cgi?id=24554 for
> clarification. Jordan, I hope you can participate in any discussion
> there?

Based on the hint from Alan Modra, it seems PROGBITS/NOBITS can be
controlled with the presence/absence of the "load" section flag. This
appears to work for both BFD and LLVM:

$ objcopy --rename-section .text=.rodata,alloc,readonly,load rodata.o rodata_objcopy.o
$ readelf -WS rodata_objcopy.o | grep \.rodata
[ 1] .rodata PROGBITS 0000000000000000 000040 000002 00 A 0 0 16

$ llvm-objcopy --rename-section .text=.rodata,alloc,readonly,load rodata.o rodata_objcopy.o
$ readelf -WS rodata_objcopy.o | grep \.rodata
[ 1] .rodata PROGBITS 0000000000000000 000040 000002 00 A 0 0 16

So, that's an easy change that could be folded into the original version
of this patch (no need for my two-phase work-around).

--
Kees Cook

\
 
 \ /
  Last update: 2019-05-15 18:43    [W:0.042 / U:10.500 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site