Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 8a1afd2 in mainline


Ignore:
Timestamp:
2018-10-17T22:51:33Z (3 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master
Children:
1d18bbc0, d723a80
Parents:
7900e5d
Message:

Remove hardcoded data variables from kernel linker scripts

Location:
kernel
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/abs32le/_link.ld.in

    r7900e5d r8a1afd2  
    11SECTIONS {
    22        .text : {
     3                kernel_load_address = .;
    34                ktext_start = .;
    45                *(.text);
     
    89                kdata_start = .;
    910                *(.data);                       /* initialized data */
    10                 hardcoded_ktext_size = .;
    11                 LONG(ktext_end - ktext_start);
    12                 hardcoded_kdata_size = .;
    13                 LONG(kdata_end - kdata_start);
    14                 hardcoded_load_address = .;
    15                 LONG(hardcoded_load_address);
    1611                *(.bss);                        /* uninitialized static variables */
    1712                *(COMMON);                      /* global variables */
  • kernel/arch/abs32le/src/mm/frame.c

    r7900e5d r8a1afd2  
    4242#include <print.h>
    4343
    44 size_t hardcoded_unmapped_ktext_size = 0;
    45 size_t hardcoded_unmapped_kdata_size = 0;
    46 
    4744void physmem_print(void)
    4845{
  • kernel/arch/amd64/_link.ld.in

    r7900e5d r8a1afd2  
    1313
    1414SECTIONS {
     15        kernel_load_address = PA2KA(BOOT_OFFSET);
     16
    1517        .unmapped BOOT_OFFSET: AT (0) {
    1618                unmapped_ktext_start = .;
     
    3234                *(.data);              /* initialized data */
    3335                *(.rodata .rodata.*);  /* string literals */
    34                 hardcoded_load_address = .;
    35                 QUAD(PA2KA(BOOT_OFFSET));
    36                 hardcoded_ktext_size = .;
    37                 QUAD(ktext_end - ktext_start + (unmapped_ktext_end - unmapped_ktext_start));
    38                 hardcoded_kdata_size = .;
    39                 QUAD(kdata_end - kdata_start + (unmapped_kdata_end - unmapped_kdata_start));
    40                 hardcoded_unmapped_ktext_size = .;
    41                 QUAD(unmapped_ktext_end - unmapped_ktext_start);
    42                 hardcoded_unmapped_kdata_size = .;
    43                 QUAD(unmapped_kdata_end - unmapped_kdata_start);
    4436                *(COMMON);      /* global variables */
    4537
     
    7163
    7264#ifdef CONFIG_SMP
    73         _hardcoded_unmapped_size = (unmapped_ktext_end - unmapped_ktext_start) + (unmapped_kdata_end - unmapped_kdata_start);
    7465        ap_boot = unmapped_ap_boot - BOOT_OFFSET + AP_BOOT_OFFSET;
    7566        ap_gdtr = unmapped_ap_gdtr - BOOT_OFFSET + AP_BOOT_OFFSET;
  • kernel/arch/amd64/include/arch/boot/boot.h

    r7900e5d r8a1afd2  
    4242#ifndef __ASSEMBLER__
    4343
    44 #ifdef CONFIG_SMP
    45 
    46 /* This is only a symbol so the type is dummy. Obtain the value using &. */
    47 extern int _hardcoded_unmapped_size;
    48 
    49 #endif /* CONFIG_SMP */
     44extern uint8_t unmapped_kdata_end[];
    5045
    5146#endif /* __ASSEMBLER__ */
  • kernel/arch/amd64/src/amd64.c

    r7900e5d r8a1afd2  
    9494
    9595#ifdef CONFIG_SMP
     96        size_t unmapped_size = (uintptr_t) unmapped_kdata_end - BOOT_OFFSET;
    9697        /* Copy AP bootstrap routines below 1 MB. */
    97         memcpy((void *) AP_BOOT_OFFSET, (void *) BOOT_OFFSET,
    98             (size_t) &_hardcoded_unmapped_size);
     98        memcpy((void *) AP_BOOT_OFFSET, (void *) BOOT_OFFSET, unmapped_size);
    9999#endif
    100100}
  • kernel/arch/arm32/_link.ld.in

    r7900e5d r8a1afd2  
    2424SECTIONS {
    2525        . = KERNEL_LOAD_ADDRESS;
     26        kernel_load_address = .;
    2627        .text : {
    2728                ktext_start = .;
     
    3233                kdata_start = .;
    3334                *(.data);                       /* initialized data */
    34                 hardcoded_ktext_size = .;
    35                 LONG(ktext_end - ktext_start);
    36                 hardcoded_kdata_size = .;
    37                 LONG(kdata_end - kdata_start);
    38                 hardcoded_load_address = .;
    39                 LONG(KERNEL_LOAD_ADDRESS);
    4035                *(.bss);                        /* uninitialized static variables */
    4136                *(COMMON);                      /* global variables */
  • kernel/arch/ia32/_link.ld.in

    r7900e5d r8a1afd2  
    1313
    1414SECTIONS {
     15        kernel_load_address = PA2KA(BOOT_OFFSET);
     16
    1517        .unmapped BOOT_OFFSET: AT (0) {
    1618                unmapped_ktext_start = .;
     
    3234                *(.rodata .rodata.*);   /* string literals */
    3335                *(COMMON);              /* global variables */
    34                 hardcoded_load_address = .;
    35                 LONG(PA2KA(BOOT_OFFSET));
    36                 hardcoded_ktext_size = .;
    37                 LONG((ktext_end - ktext_start) + (unmapped_ktext_end - unmapped_ktext_start));
    38                 hardcoded_kdata_size = .;
    39                 LONG((kdata_end - kdata_start) + (unmapped_kdata_end - unmapped_kdata_start));
    40                 hardcoded_unmapped_ktext_size = .;
    41                 LONG(unmapped_ktext_end - unmapped_ktext_start);
    42                 hardcoded_unmapped_kdata_size = .;
    43                 LONG(unmapped_kdata_end - unmapped_kdata_start);
    4436                . = ALIGN(8);
    4537                symbol_table = .;
     
    6860#ifdef CONFIG_SMP
    6961
    70         _hardcoded_unmapped_size = (unmapped_ktext_end - unmapped_ktext_start) + (unmapped_kdata_end - unmapped_kdata_start);
    7162        ap_boot = unmapped_ap_boot - BOOT_OFFSET + AP_BOOT_OFFSET;
    7263        ap_gdtr = unmapped_ap_gdtr - BOOT_OFFSET + AP_BOOT_OFFSET;
  • kernel/arch/ia32/include/arch/boot/boot.h

    r7900e5d r8a1afd2  
    4444#ifdef CONFIG_SMP
    4545
    46 /* This is only a symbol so the type is dummy. Obtain the value using &. */
    47 extern int _hardcoded_unmapped_size;
     46extern uint8_t unmapped_kdata_end[];
    4847
    4948#endif /* CONFIG_SMP */
  • kernel/arch/ia32/src/boot/multiboot.S

    r7900e5d r8a1afd2  
    285285/** Calculate unmapped address of the end of the kernel. */
    286286calc_kernel_end:
    287         movl $KA2PA(hardcoded_load_address), %edi
    288         movl (%edi), %esi
    289         leal KA2PA(0)(%esi), %esi
    290 
    291         movl $KA2PA(hardcoded_ktext_size), %edi
    292         addl (%edi), %esi
    293         leal KA2PA(0)(%esi), %esi
    294 
    295         movl $KA2PA(hardcoded_kdata_size), %edi
    296         addl (%edi), %esi
    297         leal KA2PA(0)(%esi), %esi
    298         movl %esi, kernel_end
    299 
     287        movl $KA2PA(kdata_end), %edi
     288        movl %edi, kernel_end
    300289        ret
    301290
  • kernel/arch/ia32/src/ia32.c

    r7900e5d r8a1afd2  
    9494
    9595#ifdef CONFIG_SMP
     96        size_t unmapped_size = (uintptr_t) unmapped_kdata_end - BOOT_OFFSET;
    9697        /* Copy AP bootstrap routines below 1 MB. */
    97         memcpy((void *) AP_BOOT_OFFSET, (void *) BOOT_OFFSET,
    98             (size_t) &_hardcoded_unmapped_size);
     98        memcpy((void *) AP_BOOT_OFFSET, (void *) BOOT_OFFSET, unmapped_size);
    9999#endif
    100100}
  • kernel/arch/ia32/src/mm/frame.c

    r7900e5d r8a1afd2  
    4747
    4848#define PHYSMEM_LIMIT32  UINT64_C(0x100000000)
    49 
    50 size_t hardcoded_unmapped_ktext_size = 0;
    51 size_t hardcoded_unmapped_kdata_size = 0;
    5249
    5350static void init_e820_memory(pfn_t minconf, bool low)
     
    155152
    156153#ifdef CONFIG_SMP
     154                size_t unmapped_size =
     155                    (uintptr_t) unmapped_kdata_end - BOOT_OFFSET;
     156
    157157                minconf = max(minconf,
    158                     ADDR2PFN(AP_BOOT_OFFSET + hardcoded_unmapped_ktext_size +
    159                     hardcoded_unmapped_kdata_size));
     158                    ADDR2PFN(AP_BOOT_OFFSET + unmapped_size));
    160159#endif
    161160
     
    168167                /* Reserve AP real mode bootstrap memory */
    169168                frame_mark_unavailable(AP_BOOT_OFFSET >> FRAME_WIDTH,
    170                     (hardcoded_unmapped_ktext_size +
    171                     hardcoded_unmapped_kdata_size) >> FRAME_WIDTH);
     169                    unmapped_size >> FRAME_WIDTH);
    172170#endif
    173171        }
  • kernel/arch/ia64/_link.ld.in

    r7900e5d r8a1afd2  
    1313
    1414SECTIONS {
     15        kernel_load_address = LOAD_ADDRESS_V;
     16
    1517        .image LOAD_ADDRESS_V: AT (LOAD_ADDRESS_P) {
    1618                ktext_start = .;
     
    2426                *(.opd)
    2527                *(.data .data.*)
    26                 hardcoded_load_address = .;
    27                 QUAD(LOAD_ADDRESS_V);
    28                 hardcoded_ktext_size = .;
    29                 QUAD(ktext_end - ktext_start);
    30                 hardcoded_kdata_size = .;
    31                 QUAD(kdata_end - kdata_start);
    3228                __gp = .;
    3329                *(.got .got.*)
  • kernel/arch/mips32/_link.ld.in

    r7900e5d r8a1afd2  
    2323SECTIONS {
    2424        . = KERNEL_LOAD_ADDRESS;
     25        kernel_load_address = .;
     26
    2527        .text : {
    2628                ktext_start = .;
     
    3133                kdata_start = .;
    3234                *(.data);                       /* initialized data */
    33                 hardcoded_ktext_size = .;
    34                 LONG(ktext_end - ktext_start);
    35                 hardcoded_kdata_size = .;
    36                 LONG(kdata_end - kdata_start);
    37                 hardcoded_load_address = .;
    38                 LONG(KERNEL_LOAD_ADDRESS);
    3935                *(.rodata*);
    4036                *(.sdata);
  • kernel/arch/ppc32/_link.ld.in

    r7900e5d r8a1afd2  
    1818
    1919SECTIONS {
     20        kernel_load_address = PA2KA(0);
     21
    2022        .unmapped 0: AT (0) {
    2123                unmapped_ktext_start = .;
     
    4143                *(.sdata2);
    4244                *(.sbss);
    43                 hardcoded_ktext_size = .;
    44                 LONG(ktext_end - ktext_start);
    45                 hardcoded_kdata_size = .;
    46                 LONG(kdata_end - kdata_start);
    47                 hardcoded_load_address = .;
    48                 LONG(PA2KA(BOOT_OFFSET));
    4945                *(.bss);        /* uninitialized static variables */
    5046                *(COMMON);      /* global variables */
  • kernel/arch/riscv64/_link.ld.in

    r7900e5d r8a1afd2  
    1414
    1515SECTIONS {
     16        kernel_load_address = PA2KA(BOOT_OFFSET);
     17
    1618        .image (PA2KA(BOOT_OFFSET)) : AT (0) {
    1719                ktext_start = .;
     
    2325                *(.data);                       /* initialized data */
    2426                *(.rodata*);
    25                 hardcoded_load_address = .;
    26                 QUAD(PA2KA(BOOT_OFFSET));
    27                 hardcoded_ktext_size = .;
    28                 QUAD(ktext_end - ktext_start);
    29                 hardcoded_kdata_size = .;
    30                 QUAD(kdata_end - kdata_start);
    3127                *(.sdata);
    3228                *(.reginfo);
  • kernel/arch/sparc64/_link.ld.in

    r7900e5d r8a1afd2  
    1313SECTIONS {
    1414        .image VMA: AT (LMA) {
     15                kernel_load_address = .;
     16
    1517                ktext_start = .;
    1618                *(K_TEXT_START)
     
    2628                *(.sbss);
    2729                . = ALIGN(8);
    28                 hardcoded_ktext_size = .;
    29                 QUAD(ktext_end - ktext_start);
    30                 hardcoded_kdata_size = .;
    31                 QUAD(kdata_end - kdata_start);
    32                 hardcoded_load_address = .;
    33                 QUAD(VMA);
    3430                *(.bss);                    /* uninitialized static variables */
    3531                *(COMMON);                  /* global variables */
  • kernel/generic/include/main/main.h

    r7900e5d r8a1afd2  
    3838#include <typedefs.h>
    3939
    40 extern size_t hardcoded_kdata_size;
    41 extern size_t hardcoded_ktext_size;
    42 extern uintptr_t hardcoded_load_address;
     40/* Address of the start of the kernel image. */
     41extern uint8_t kernel_load_address[];
     42/* Address of the end of kernel. */
     43extern uint8_t kdata_end[];
     44
    4345extern uintptr_t stack_safe;
    4446
  • kernel/generic/src/main/main.c

    r7900e5d r8a1afd2  
    168168        config.cpu_active = 1;
    169169
    170         config.base = hardcoded_load_address;
    171         config.kernel_size = ALIGN_UP(hardcoded_ktext_size +
    172             hardcoded_kdata_size, PAGE_SIZE);
     170        config.base = (uintptr_t) kernel_load_address;
     171
     172        config.kernel_size =
     173            ALIGN_UP((uintptr_t) kdata_end - config.base, PAGE_SIZE);
    173174        config.stack_size = STACK_SIZE;
    174175
Note: See TracChangeset for help on using the changeset viewer.