Advertisement
Guest User

Untitled

a guest
Oct 6th, 2023
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. /* Tell the linker that we want an x86_64 ELF64 output file */
  2. OUTPUT_FORMAT(elf64-x86-64)
  3. OUTPUT_ARCH(i386:x86-64)
  4.  
  5. /* We want the symbol _start to be our entry point */
  6. ENTRY(_start)
  7.  
  8. /* Define the program headers we want so the bootloader gives us the right */
  9. /* MMU permissions */
  10. PHDRS
  11. {
  12. text PT_LOAD FLAGS((1 << 0) | (1 << 2)) ; /* Execute + Read */
  13. rodata PT_LOAD FLAGS((1 << 2)) ; /* Read only */
  14. data PT_LOAD FLAGS((1 << 1) | (1 << 2)) ; /* Write + Read */
  15. }
  16.  
  17. SECTIONS
  18. {
  19. /* We wanna be placed in the topmost 2GiB of the address space, for optimisations */
  20. /* and because that is what the Limine spec mandates. */
  21. /* Any address in this region will do, but often 0xffffffff80000000 is chosen as */
  22. /* that is the beginning of the region. */
  23. . = 0xffffffff80000000;
  24.  
  25. .text : {
  26. *(.text .text.*)
  27. } :text
  28.  
  29. /* Move to the next memory page for .rodata */
  30. . += CONSTANT(MAXPAGESIZE);
  31.  
  32. .rodata : {
  33. *(.rodata .rodata.*)
  34. } :rodata
  35.  
  36. /* Move to the next memory page for .data */
  37. . += CONSTANT(MAXPAGESIZE);
  38.  
  39. .data : {
  40. *(.data .data.*)
  41. } :data
  42.  
  43. /* NOTE: .bss needs to be the last thing mapped to :data, otherwise lots of */
  44. /* unnecessary zeros will be written to the binary. */
  45. /* If you need, for example, .init_array and .fini_array, those should be placed */
  46. /* above this. */
  47. .bss : {
  48. *(COMMON)
  49. *(.bss .bss.*)
  50. } :data
  51.  
  52. /* Discard .note.* and .eh_frame since they may cause issues on some hosts. */
  53. /DISCARD/ : {
  54. *(.eh_frame)
  55. *(.note .note.*)
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement