link.ld 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * mykernel/rust/link.ld
  3. *
  4. * Copyright (C) 2017 - 2021 Vinay Chandra
  5. *
  6. * Permission is hereby granted, free of charge, to any person
  7. * obtaining a copy of this software and associated documentation
  8. * files (the "Software"), to deal in the Software without
  9. * restriction, including without limitation the rights to use, copy,
  10. * modify, merge, publish, distribute, sublicense, and/or sell copies
  11. * of the Software, and to permit persons to whom the Software is
  12. * furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be
  15. * included in all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  18. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  20. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  21. * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  22. * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  24. * DEALINGS IN THE SOFTWARE.
  25. *
  26. * This file is part of the BOOTBOOT Protocol package.
  27. * @brief An example linker script for sample kernel
  28. *
  29. */
  30. ENTRY(_start)
  31. mmio = 0xfffffffff8000000; /* these are configurable for level 2 loaders */
  32. fb = 0xfffffffffc000000;
  33. bootboot = 0xffffffffffe00000;
  34. environment = 0xffffffffffe01000;
  35. initstack = 4096;
  36. KERNEL_OFFSET = 0xffffffffffe02000;
  37. PHDRS
  38. {
  39. boot PT_LOAD FILEHDR PHDRS; /* one single loadable segment */
  40. }
  41. SECTIONS
  42. {
  43. . = 0xffffffffffe02000;
  44. .text . + SIZEOF_HEADERS : AT(ADDR(.text) - KERNEL_OFFSET + SIZEOF_HEADERS) {
  45. __text_start = .;
  46. KEEP(*(.text.boot)) *(.text .text.* .gnu.linkonce.t*) /* code */
  47. . = ALIGN(4096);
  48. __text_end = .;
  49. } :boot
  50. .rodata : AT(ADDR(.rodata) - KERNEL_OFFSET) {
  51. __rodata_start = .;
  52. *(.rodata*)
  53. . = ALIGN(4096);
  54. __rodata_end = .;
  55. } :boot
  56. .data : AT(ADDR(.data) - KERNEL_OFFSET) {
  57. __data_start = .;
  58. *(.data*)
  59. . = ALIGN(4096);
  60. __data_end = .;
  61. __bss_start = .;
  62. *(.bss*)
  63. . = ALIGN(4096);
  64. __bss_end = .;
  65. } :boot
  66. /DISCARD/ : { *(.eh_frame) *(.comment) }
  67. }