bool "M68000 architecture"
select HAVE_PRIVATE_LIBGCC
select USE_PRIVATE_LIBGCC
- select NEEDS_MANUAL_RELOC
select SYS_BOOT_GET_CMDLINE
select SYS_BOOT_GET_KBD
select SYS_CACHE_SHIFT_4
config SYS_ARCH
default "m68k"
-config NEEDS_MANUAL_RELOC
- def_bool y
+config STATIC_RELA
+ default y
# processor family
config MCF520x
# (C) Copyright 2000-2002
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
-PLATFORM_CPPFLAGS += -D__M68K__
-KBUILD_LDFLAGS += -n
+PLATFORM_CPPFLAGS += -D__M68K__ -fPIC
+KBUILD_LDFLAGS += -n -pie
PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
PLATFORM_RELFLAGS += -ffixed-d7 -msep-data
-LDFLAGS_FINAL += --gc-sections
+LDFLAGS_FINAL += --gc-sections -pie
cmp.l %a1,%a2
bgt.s 1b
+#define R_68K_32 1
+#define R_68K_RELATIVE 22
+
+ move.l #(__rel_dyn_start), %a1
+ move.l #(__rel_dyn_end), %a2
+
+fixloop:
+ move.l (%a1)+, %d1 /* Elf32_Rela r_offset */
+ move.l (%a1)+, %d2 /* Elf32_Rela r_info */
+ move.l (%a1)+, %d3 /* Elf32_Rela r_addend */
+
+ andi.l #0xff, %d2
+ cmp.l #R_68K_32, %d2
+ beq.s fixup
+ cmp.l #R_68K_RELATIVE, %d2
+ beq.s fixup
+
+ bra fixnext
+
+fixup:
+ /* relative fix: store addend plus offset at dest location */
+ move.l %a0, %a3
+ add.l %d1, %a3
+ sub.l #CONFIG_SYS_MONITOR_BASE, %a3
+ move.l (%a3), %d4
+ add.l %a0, %d4
+ sub.l #CONFIG_SYS_MONITOR_BASE, %d4
+ move.l %d4, (%a3)
+
+fixnext:
+ cmp.l %a1, %a2
+ bge.s fixloop
+
/*
* We are done. Do not return, instead branch to second part of board
* initialization, now running from RAM.
/*
* Now clear BSS segment
*/
- move.l %a0, %a1
- add.l #(_sbss - CONFIG_SYS_MONITOR_BASE),%a1
- move.l %a0, %d1
- add.l #(_ebss - CONFIG_SYS_MONITOR_BASE),%d1
+ move.l #(_sbss), %a1
+ move.l #(_ebss), %d1
6:
clr.l (%a1)+
cmp.l %a1,%d1
/*
* fix got table in RAM
*/
- move.l %a0, %a1
- add.l #(__got_start - CONFIG_SYS_MONITOR_BASE),%a1
- move.l %a1,%a5 /* * fix got pointer register a5 */
-
- move.l %a0, %a2
- add.l #(__got_end - CONFIG_SYS_MONITOR_BASE),%a2
-
-7:
- move.l (%a1),%d1
- sub.l #_start,%d1
- add.l %a0,%d1
- move.l %d1,(%a1)+
- cmp.l %a2, %a1
- bne 7b
+ move.l #(__got_start), %a5 /* fix got pointer register a5 */
/* calculate relative jump to board_init_r in ram */
- move.l %a0, %a1
- add.l #(board_init_r - CONFIG_SYS_MONITOR_BASE), %a1
+ move.l #(board_init_r), %a1
/* set parameters for board_init_r */
move.l %a0,-(%sp) /* dest_addr */
cmp.l %a1,%a2
bgt.s 1b
+#define R_68K_32 1
+#define R_68K_RELATIVE 22
+
+ move.l #(__rel_dyn_start), %a1
+ move.l #(__rel_dyn_end), %a2
+
+fixloop:
+ move.l (%a1)+, %d1 /* Elf32_Rela r_offset */
+ move.l (%a1)+, %d2 /* Elf32_Rela r_info */
+ move.l (%a1)+, %d3 /* Elf32_Rela r_addend */
+
+ andi.l #0xff, %d2
+ cmp.l #R_68K_32, %d2
+ beq.s fixup
+ cmp.l #R_68K_RELATIVE, %d2
+ beq.s fixup
+
+ bra fixnext
+
+fixup:
+ /* relative fix: store addend plus offset at dest location */
+ move.l %a0, %a3
+ add.l %d1, %a3
+ sub.l #CONFIG_SYS_MONITOR_BASE, %a3
+ move.l (%a3), %d4
+ add.l %a0, %d4
+ sub.l #CONFIG_SYS_MONITOR_BASE, %d4
+ move.l %d4, (%a3)
+
+fixnext:
+ cmp.l %a1, %a2
+ bge.s fixloop
+
/*
* We are done. Do not return, instead branch to second part of board
* initialization, now running from RAM.
/*
* Now clear BSS segment
*/
- move.l %a0, %a1
- add.l #(_sbss - CONFIG_SYS_MONITOR_BASE),%a1
- move.l %a0, %d1
- add.l #(_ebss - CONFIG_SYS_MONITOR_BASE),%d1
+ move.l #(_sbss), %a1
+ move.l #(_ebss), %d1
6:
clr.l (%a1)+
cmp.l %a1,%d1
/*
* fix got table in RAM
*/
- move.l %a0, %a1
- add.l #(__got_start - CONFIG_SYS_MONITOR_BASE),%a1
- move.l %a1,%a5 /* fix got pointer register a5 */
-
- move.l %a0, %a2
- add.l #(__got_end - CONFIG_SYS_MONITOR_BASE),%a2
-
-7:
- move.l (%a1),%d1
- sub.l #_start,%d1
- add.l %a0,%d1
- move.l %d1,(%a1)+
- cmp.l %a2, %a1
- bne 7b
+ move.l #(__got_start), %a5 /* fix got pointer register a5 */
/* calculate relative jump to board_init_r in ram */
- move.l %a0, %a1
- add.l #(board_init_r - CONFIG_SYS_MONITOR_BASE), %a1
+ move.l #(board_init_r), %a1
/* set parameters for board_init_r */
move.l %a0,-(%sp) /* dest_addr */
cmp.l %a1,%a2
bgt.s 1b
+#define R_68K_32 1
+#define R_68K_RELATIVE 22
+
+ move.l #(__rel_dyn_start), %a1
+ move.l #(__rel_dyn_end), %a2
+
+fixloop:
+ move.l (%a1)+, %d1 /* Elf32_Rela r_offset */
+ move.l (%a1)+, %d2 /* Elf32_Rela r_info */
+ move.l (%a1)+, %d3 /* Elf32_Rela r_addend */
+
+ andi.l #0xff, %d2
+ cmp.l #R_68K_32, %d2
+ beq.s fixup
+ cmp.l #R_68K_RELATIVE, %d2
+ beq.s fixup
+
+ bra fixnext
+
+fixup:
+ /* relative fix: store addend plus offset at dest location */
+ move.l %a0, %a3
+ add.l %d1, %a3
+ sub.l #CONFIG_SYS_MONITOR_BASE, %a3
+ move.l (%a3), %d4
+ add.l %a0, %d4
+ sub.l #CONFIG_SYS_MONITOR_BASE, %d4
+ move.l %d4, (%a3)
+
+fixnext:
+ cmp.l %a1, %a2
+ bge.s fixloop
+
/*
* We are done. Do not return, instead branch to second part of board
* initialization, now running from RAM.
/*
* Now clear BSS segment
*/
- move.l %a0, %a1
- add.l #(_sbss - CONFIG_SYS_MONITOR_BASE), %a1
- move.l %a0, %d1
- add.l #(_ebss - CONFIG_SYS_MONITOR_BASE), %d1
+ move.l #(_sbss), %a1
+ move.l #(_ebss), %d1
6:
clr.l (%a1)+
cmp.l %a1,%d1
/*
* fix got table in RAM
*/
- move.l %a0, %a1
- add.l #(__got_start - CONFIG_SYS_MONITOR_BASE), %a1
-
- /* fix got pointer register a5 */
- move.l %a1,%a5
-
- move.l %a0, %a2
- add.l #(__got_end - CONFIG_SYS_MONITOR_BASE), %a2
-
-7:
- move.l (%a1),%d1
- sub.l #_start, %d1
- add.l %a0,%d1
- move.l %d1,(%a1)+
- cmp.l %a2, %a1
- bne 7b
+ move.l #(__got_start), %a5 /* fix got pointer register a5 */
/* calculate relative jump to board_init_r in ram */
- move.l %a0, %a1
- add.l #(board_init_r - CONFIG_SYS_MONITOR_BASE), %a1
+ move.l #(board_init_r), %a1
/* set parameters for board_init_r */
move.l %a0,-(%sp) /* dest_addr */
cmp.l %a1,%a2
bgt.s 1b
+#define R_68K_32 1
+#define R_68K_RELATIVE 22
+
+ move.l #(__rel_dyn_start), %a1
+ move.l #(__rel_dyn_end), %a2
+
+fixloop:
+ move.l (%a1)+, %d1 /* Elf32_Rela r_offset */
+ move.l (%a1)+, %d2 /* Elf32_Rela r_info */
+ move.l (%a1)+, %d3 /* Elf32_Rela r_addend */
+
+ andi.l #0xff, %d2
+ cmp.l #R_68K_32, %d2
+ beq.s fixup
+ cmp.l #R_68K_RELATIVE, %d2
+ beq.s fixup
+
+ bra fixnext
+
+fixup:
+ /* relative fix: store addend plus offset at dest location */
+ move.l %a0, %a3
+ add.l %d1, %a3
+ sub.l #CONFIG_SYS_MONITOR_BASE, %a3
+ move.l (%a3), %d4
+ add.l %a0, %d4
+ sub.l #CONFIG_SYS_MONITOR_BASE, %d4
+ move.l %d4, (%a3)
+
+fixnext:
+ cmp.l %a1, %a2
+ bge.s fixloop
+
/*
* We are done. Do not return, instead branch to second part of board
* initialization, now running from RAM.
/*
* Now clear BSS segment
*/
- move.l %a0, %a1
- add.l #(_sbss - CONFIG_SYS_MONITOR_BASE),%a1
- move.l %a0, %d1
- add.l #(_ebss - CONFIG_SYS_MONITOR_BASE),%d1
+ move.l #(_sbss), %a1
+ move.l #(_ebss), %d1
6:
clr.l (%a1)+
cmp.l %a1,%d1
/*
* fix got table in RAM
*/
- move.l %a0, %a1
- add.l #(__got_start - CONFIG_SYS_MONITOR_BASE),%a1
- move.l %a1,%a5 /* fix got pointer register a5 */
-
- move.l %a0, %a2
- add.l #(__got_end - CONFIG_SYS_MONITOR_BASE),%a2
-
-7:
- move.l (%a1),%d1
- sub.l #_start,%d1
- add.l %a0,%d1
- move.l %d1,(%a1)+
- cmp.l %a2, %a1
- bne 7b
+ move.l #(__got_start), %a5 /* fix got pointer register a5 */
/* calculate relative jump to board_init_r in ram */
- move.l %a0, %a1
- add.l #(board_init_r - CONFIG_SYS_MONITOR_BASE), %a1
+ move.l #(board_init_r), %a1
/* set parameters for board_init_r */
move.l %a0,-(%sp) /* dest_addr */
cmp.l %a1,%a2
bgt.s 1b
+#define R_68K_32 1
+#define R_68K_RELATIVE 22
+
+ move.l #(__rel_dyn_start), %a1
+ move.l #(__rel_dyn_end), %a2
+
+fixloop:
+ move.l (%a1)+, %d1 /* Elf32_Rela r_offset */
+ move.l (%a1)+, %d2 /* Elf32_Rela r_info */
+ move.l (%a1)+, %d3 /* Elf32_Rela r_addend */
+
+ andi.l #0xff, %d2
+ cmp.l #R_68K_32, %d2
+ beq.s fixup
+ cmp.l #R_68K_RELATIVE, %d2
+ beq.s fixup
+
+ bra fixnext
+
+fixup:
+ /* relative fix: store addend plus offset at dest location */
+ move.l %a0, %a3
+ add.l %d1, %a3
+ sub.l #CONFIG_SYS_MONITOR_BASE, %a3
+ move.l (%a3), %d4
+ add.l %a0, %d4
+ sub.l #CONFIG_SYS_MONITOR_BASE, %d4
+ move.l %d4, (%a3)
+
+fixnext:
+ cmp.l %a1, %a2
+ bge.s fixloop
+
/*
* We are done. Do not return, instead branch to second part of board
* initialization, now running from RAM.
/*
* Now clear BSS segment
*/
- move.l %a0, %a1
- add.l #(_sbss - CONFIG_SYS_MONITOR_BASE),%a1
- move.l %a0, %d1
- add.l #(_ebss - CONFIG_SYS_MONITOR_BASE),%d1
+ move.l #(_sbss), %a1
+ move.l #(_ebss), %d1
6:
clr.l (%a1)+
cmp.l %a1,%d1
/*
* fix got table in RAM
*/
- move.l %a0, %a1
- add.l #(__got_start - CONFIG_SYS_MONITOR_BASE),%a1
- move.l %a1,%a5 /* fix got pointer register a5 */
-
- move.l %a0, %a2
- add.l #(__got_end - CONFIG_SYS_MONITOR_BASE),%a2
-
-7:
- move.l (%a1),%d1
- sub.l #_start,%d1
- add.l %a0,%d1
- move.l %d1,(%a1)+
- cmp.l %a2, %a1
- bne 7b
+ move.l #(__got_start), %a5 /* fix got pointer register a5 */
/* calculate relative jump to board_init_r in ram */
- move.l %a0, %a1
- add.l #(board_init_r - CONFIG_SYS_MONITOR_BASE), %a1
+ move.l #(board_init_r), %a1
/* set parameters for board_init_r */
move.l %a0,-(%sp) /* dest_addr */
. = ALIGN(4);
__init_end = .;
+ . = ALIGN(4);
+ __rel_dyn_start = .;
+ .rela.dyn : {
+ *(.rela.dyn)
+ }
+ __rel_dyn_end = .;
+
+ . = ALIGN(4);
+ __dyn_sym_start = .;
+ .dynsym : {
+ *(.dynsym)
+ }
+ __dyn_sym_end = .;
+
_end = .;
__bss_start = .;