linux-rockchip/scripts
Russ Dill 2ecab0b339 PIE: Support embedding position independent executables
This commit adds support for embedding PIEs into the kernel, loading them
into genalloc sections, performing necessary relocations, and running code
from them. This allows platforms that need to run code from SRAM, such
an during suspend/resume, to develop that code in C instead of assembly.

Functions and data for each PIE should be grouped into sections with the
__pie(<group>) and __pie_data(<group>) macros respectively. Any symbols or
functions that are to be accessed from outside the PIE should be marked with
EXPORT_PIE_SYMBOL(<sym>). For example:

static struct ddr_timings xyz_timings __pie_data(platformxyz) = {
	[...]
};

void __pie(platformxyz) xyz_ddr_on(void *addr)
{
	[...]
}
EXPORT_PIE_SYMBOL(xyz_ddr_on);

While the kernel can access exported symbols from the PIE, the PIE cannot
access symbols from the kernel, but can access data from the kernel and
call functions in the kernel so long as addresses are passed into the PIE.

PIEs are loaded from the kernel into a genalloc pool with pie_load_sections.
pie_load_sections allocates space within the pool, copies the neccesary
code/data, and performs any necessary relocations. A chunk identifier is
returned for removing the PIE from the pool, and for translating symbols.

Because the PIEs are dynamically relocated, special accessors must be used
to access PIE symbols from kernel code:

- kern_to_pie(chunk, ptr):   Translate a PIE symbol to the virtual address
                             it is loaded into within the pool.

- fn_to_pie(chunk, ptr):     Same as above, but for function pointers.

- sram_to_phys(chunk, addr): Translate a virtual address within a loaded PIE
                             to a physical address.

Loading a PIE involves three main steps. First a set of common functions to
cover built-ins emitted by gcc (memcpy, memmove, etc) is copied into the pool.
Then the actual PIE code and data is copied into the pool. Because the PIE
code is contained within an overlay with other PIEs, offsets to the common
functions are maintained. Finally, relocations are performed as necessary.

Signed-off-by: Russ Dill <Russ.Dill@ti.com>
2013-11-21 13:39:21 +08:00
..
basic kbuild: fixdep: support concatenated dep files 2013-04-05 12:22:58 -06:00
coccinelle Merge branch 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild 2013-02-27 12:27:18 -08:00
dtc dtc: ensure #line directives don't consume data from the next line 2013-06-13 22:12:15 +01:00
genksyms genksyms: pass symbol-prefix instead of arch 2013-03-20 11:27:27 +10:30
kconfig rk: revert 20f3d0b+v3.0.66 to v3.0 2013-11-08 21:34:05 +08:00
ksymoops
mod rk: revert 20f3d0b+v3.0.66 to v3.0 2013-11-08 21:34:05 +08:00
package rk: revert 20f3d0b+v3.0.66 to v3.0 2013-11-08 21:34:05 +08:00
rt-tester
selinux
tracing
.gitignore rk: temp revert rk change 2013-11-08 21:33:42 +08:00
asn1_compiler.c X.509: Add simple ASN.1 grammar compiler 2012-10-08 13:50:19 +10:30
bin2c.c
bloat-o-meter
bmptologo.c
bootgraph.pl
checkincludes.pl
checkkconfigsymbols.sh
checkpatch.pl checkpatch: add Suggested-by as a standard signature 2013-04-29 18:28:20 -07:00
checkstack.pl scripts/checkstack.pl: Add metag support 2013-03-02 20:09:55 +00:00
checksyscalls.sh
checkversion.pl
cleanfile
cleanpatch
coccicheck Coccinelle: Fix patch output when coccicheck is used with M= and C= 2013-04-08 15:42:03 +02:00
config scripts/config: fix assignment of parameters for short version of --*-after options 2013-05-20 14:15:17 +02:00
conmakehash.c
decodecode scripts/decodecode: make faulting insn ptr more robust 2013-04-29 15:54:27 -07:00
depmod.sh depmod: pass -P $CONFIG_SYMBOL_PREFIX 2013-02-22 11:52:31 +01:00
diffconfig
docproc.c
export_report.pl
extract-ikconfig
extract-vmlinux
gcc-goto.sh
gcc-version.sh rk: revert 20f3d0b+v3.0.66 to v3.0 2013-11-08 21:34:05 +08:00
gcc-x86_32-has-stack-protector.sh rk: revert 20f3d0b+v3.0.66 to v3.0 2013-11-08 21:34:05 +08:00
gcc-x86_64-has-stack-protector.sh rk: revert 20f3d0b+v3.0.66 to v3.0 2013-11-08 21:34:05 +08:00
gen_initramfs_list.sh
get_maintainer.pl get_maintainer: use filename-only regex match for Tegra 2013-04-29 18:28:14 -07:00
gfp-translate
headerdep.pl
headers.sh
headers_check.pl
headers_install.sh headers_install.pl: convert to headers_install.sh 2013-04-09 12:50:29 +02:00
kallsyms.c scripts/kallsyms: filter symbols not in kernel address space 2013-11-13 12:05:32 +09:00
Kbuild.include rk: revert 20f3d0b+v3.0.66 to v3.0 2013-11-08 21:34:05 +08:00
kernel-doc scripts/kernel-doc: handle struct member __aligned without numbers 2013-02-27 19:10:09 -08:00
Lindent
link-vmlinux.sh PIE: Support embedding position independent executables 2013-11-21 13:39:21 +08:00
Makefile rk: temp revert rk change 2013-11-08 21:33:42 +08:00
Makefile.asm-generic uapi: Allow automatic generation of uapi/asm/ header files 2012-10-17 12:25:44 +01:00
Makefile.build rk: temp revert rk change 2013-11-08 21:33:42 +08:00
Makefile.clean
Makefile.fwinst kbuild: Fix accidental revert in commit fe04ddf 2012-10-15 13:01:05 -07:00
Makefile.headersinst headers_install.pl: convert to headers_install.sh 2013-04-09 12:50:29 +02:00
Makefile.help
Makefile.host
Makefile.lib Revert "ARM: convert build of appended dtb zImage to list of dtbs" 2013-07-02 14:49:32 -07:00
Makefile.modbuiltin
Makefile.modinst modules: don't break modules_install on external modules with no key. 2012-11-06 11:52:24 +10:30
Makefile.modpost modpost: handle huge numbers of modules. 2013-04-05 11:48:10 +10:30
Makefile.modsign MODSIGN: Add modules_sign make target 2012-12-14 13:05:28 +10:30
makelst
markup_oops.pl
mkcompile_h
mkmakefile
mksysmap
mkuboot.sh
mkversion
module-common.lds
namespace.pl
patch-kernel
pnmtologo.c rk: temp revert rk change 2013-11-08 21:33:42 +08:00
profile2linkerlist.pl
recordmcount.c metag: ftrace support 2013-03-02 20:09:55 +00:00
recordmcount.h rk: revert 20f3d0b+v3.0.66 to v3.0 2013-11-08 21:34:05 +08:00
recordmcount.pl
setlocalversion kbuild: Unset language specific variables in setlocalversion script 2013-02-22 14:18:30 +01:00
show_delta
sign-file MODSIGN: Add -s <signature> option to sign-file 2013-01-25 16:55:36 +10:30
sortextable.c ARM: 7568/1: Sort exception table at compile time 2012-11-04 10:31:16 +00:00
sortextable.h scripts/sortextable: silence script output 2013-02-14 15:04:41 +01:00
tags.sh scripts/tags.sh: Add magic for OFFSET and DEFINE 2013-03-27 14:22:03 +01:00
unifdef.c
ver_linux
xz_wrap.sh