phy: rockchip-inno-usb2: rm phy_power_on/off in suspend/resume cases.
[firefly-linux-kernel-4.4.55.git] / pie / Makefile
1 #
2 # linux/pie/Makefile
3 #
4 # Copyright 2013 Texas Instruments, Inc.
5 #      Russ Dill <russ.dill@ti.com>
6 #
7 # This program is free software; you can redistribute it and/or modify it
8 # under the terms and conditions of the GNU General Public License,
9 # version 2, as published by the Free Software Foundation.
10 #
11
12 obj-y           := pie.bin.o
13
14 # Report unresolved symbol references
15 ldflags-y       += --no-undefined
16 # Delete all temporary local symbols
17 ldflags-y       += -X
18
19 # Reset objcopy flags, ARM puts "-O binary" here
20 OBJCOPYFLAGS    =
21
22 # Reference gcc builtins for use in PIE with __pie_
23 $(obj)/pie_rename.syms: $(KBUILD_LIBPIE)
24         @$(NM) $^ | awk '{if ($$3) print $$3,"__pie_"$$3}' > $@
25
26 # For weakening the links to the original gcc builtins
27 $(obj)/pie_weaken.syms: $(KBUILD_LIBPIE)
28         @$(NM) $^ | awk '{if ($$3) print "__pie_"$$3}' > $@
29
30 # For embedding address of the symbols copied from the PIE into the kernel
31 $(obj)/pie.syms: $(obj)/pie.elf
32         @$(NM) $^ | awk '{if ($$3 && $$2 == toupper($$2)) print $$3,"=","0x"$$1" + _binary_pie_pie_bin_start;"}' > $@
33
34 # Collect together the libpie objects
35 LDFLAGS_libpie_stage1.o += -r
36
37 $(obj)/libpie_stage1.o: $(KBUILD_LIBPIE)
38         $(call if_changed,ld)
39
40 # Rename the libpie gcc builtins with a __pie_ prefix
41 OBJCOPYFLAGS_libpie_stage2.o += --redefine-syms=$(obj)/pie_rename.syms
42 OBJCOPYFLAGS_libpie_stage2.o += --rename-section .text=.pie.text
43
44 $(obj)/libpie_stage2.o: $(obj)/libpie_stage1.o $(obj)/pie_rename.syms
45         $(call if_changed,objcopy)
46
47 # Generate a version of vmlinux.o with weakened and rename references to gcc
48 # builtins.
49 OBJCOPYFLAGS_pie_stage1.o += --weaken-symbols=$(obj)/pie_weaken.syms
50 OBJCOPYFLAGS_pie_stage1.o += --redefine-syms=$(obj)/pie_rename.syms
51
52 $(obj)/pie_stage1.o: $(obj)/../vmlinux.o $(obj)/pie_rename.syms $(obj)/pie_weaken.syms
53         $(call if_changed,objcopy)
54
55 # Drop in the PIE versions instead
56 LDFLAGS_pie_stage2.o += -r
57 # Allow the _GLOBAL_OFFSET_TABLE to redefine
58 LDFLAGS_pie_stage2.o += --defsym=_GLOBAL_OFFSET_TABLE_=_GLOBAL_OFFSET_TABLE_
59
60 $(obj)/pie_stage2.o: $(obj)/pie_stage1.o $(obj)/libpie_stage2.o
61         $(call if_changed,ld)
62
63 # Drop everything but the pie sections
64 OBJCOPYFLAGS_pie_stage3.o += -j ".pie.*"
65 OBJCOPYFLAGS_pie_stage3.o += -j ".pie.text"
66 OBJCOPYFLAGS_pie_stage3.o += -j ".pie.rk3036.text" -j ".pie.rk3036.data"
67 OBJCOPYFLAGS_pie_stage3.o += -j ".pie.rk312x.text" -j ".pie.rk312x.data"
68 OBJCOPYFLAGS_pie_stage3.o += -j ".pie.rk3126b.text" -j ".pie.rk3126b.data"
69 OBJCOPYFLAGS_pie_stage3.o += -j ".pie.rk3188.text" -j ".pie.rk3188.data"
70 OBJCOPYFLAGS_pie_stage3.o += -j ".pie.rk3288.text" -j ".pie.rk3288.data"
71
72 $(obj)/pie_stage3.o: $(obj)/pie_stage2.o
73         $(call if_changed,objcopy)
74
75 # Create the position independant executable
76 LDFLAGS_pie.elf += -T $(KBUILD_PIE_LDS) --pie --gc-sections
77
78 $(obj)/pie.elf: $(obj)/pie_stage3.o $(KBUILD_PIE_LDS)
79         $(call if_changed,ld)
80
81 # Create binary data for the kernel
82 OBJCOPYFLAGS_pie.bin += -O binary
83
84 $(obj)/pie.bin: $(obj)/pie.elf $(obj)/pie.syms
85         $(call if_changed,objcopy)
86
87 # Import the data into the kernel
88 OBJCOPYFLAGS_pie.bin.o += -B $(ARCH) -I binary -O $(OBJCOPY_OUTPUT_FORMAT)
89
90 $(obj)/pie.bin.o: $(obj)/pie.bin
91         $(call if_changed,objcopy)
92
93 extra-y += pie_rename.syms pie_weaken.syms pie.syms pie.elf pie.bin