In-place changes to a target?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I'm attempting to do some strange things in drivers/misc/lkdtm.c, and
I'm stumped on how to do it "best" in kbuild.

What I want: an empty function that just returns, but the code lives in .rodata.

Since I want to be architecture agnostic, I want to use gcc to
generate assembly. If I force the section name (via
"__section(.rodata)" gcc adds the wrong flags ("ax" instead of "a"). I
can't trick the assembler output using a comment because each
architecture has different comment characters (once again, I want to
be architecture agnostic).

I can use objcopy to change the flags, but kbuild expects to copy from
one target to another target, rather than doing it in-place:

OBJCOPYFLAGS_lkdtm_objcopy.o := \
                        --set-section-flags .text.rodata=alloc,readonly \
                        --rename-section .text.rodata=.rodata
$(obj)/lkdtm_objcopy.o: $(src)/lkdtm.o FORCE
        $(call if_changed,objcopy)

But I haven't found a way to either replace this new target or even
add it (if built from a separate file) without also needing to rename
lkdtm.c. If I do this:

lkdtm-$(CONFIG_LKDTM) += lkdtm_objcopy.o

I end up with a circular dependency. I can't find a way to have either
lkdtm_objcopy.o replace lkdtm.o or even to simply add lkdtm_objcopy.o
to lkdtm.o without renaming lkdtm.c. For example, this works (after a
"mv lkdtm.c lkdtm_core.c" and putting the special function in a
separate file named "lkdtm_rodata.c"):

lkdtm-$(CONFIG_LKDTM)          += lkdtm_core.o
lkdtm-$(CONFIG_LKDTM)          += lkdtm_rodata_objcopy.o

OBJCOPYFLAGS_lkdtm_rodata_objcopy.o := \
                       --set-section-flags .text.rodata=alloc,readonly \
                       --rename-section .text.rodata=.rodata
$(obj)/lkdtm_rodata_objcopy.o: $(obj)/lkdtm_rodata.o
       $(call if_changed,objcopy)

Is there some way to either append to the lkdtm.o rule to do an
in-place objcopy, or append another .o file to lkdtm.o? I'd really
rather not have to rename lkdtm.c...

Thanks for any help!

-Kees

-- 
Kees Cook
Chrome OS & Brillo Security
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux