-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for GNU Linker Script (#3373)
- Loading branch information
1 parent
1b1d673
commit 33f2cf9
Showing
17 changed files
with
319 additions
and
3 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Prism.languages['linker-script'] = { | ||
'comment': { | ||
pattern: /(^|\s)\/\*[\s\S]*?(?:$|\*\/)/, | ||
lookbehind: true, | ||
greedy: true | ||
}, | ||
'identifier': { | ||
pattern: /"[^"\r\n]*"/, | ||
greedy: true | ||
}, | ||
|
||
'location-counter': { | ||
pattern: /\B\.\B/, | ||
alias: 'important' | ||
}, | ||
|
||
'section': { | ||
pattern: /(^|[^\w*])\.\w+\b/, | ||
lookbehind: true, | ||
alias: 'keyword' | ||
}, | ||
'function': /\b[A-Z][A-Z_]*(?=\s*\()/, | ||
|
||
'number': /\b(?:0[xX][a-fA-F0-9]+|\d+)[KM]?\b/, | ||
|
||
'operator': />>=?|<<=?|->|\+\+|--|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?/, | ||
'punctuation': /[(){},;]/ | ||
}; | ||
|
||
Prism.languages['ld'] = Prism.languages['linker-script']; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<h2>Full example</h2> | ||
<pre><code>/* Source: https://github.com/stivale/stivale2-barebones/blob/master/kernel/linker.ld */ | ||
|
||
/* We want the symbol _start to be our entry point */ | ||
ENTRY(_start) | ||
|
||
/* Define the program headers we want so the bootloader gives us the right */ | ||
/* MMU permissions */ | ||
PHDRS | ||
{ | ||
null PT_NULL FLAGS(0) ; /* Null segment */ | ||
text PT_LOAD FLAGS((1 << 0) | (1 << 2)) ; /* Execute + Read */ | ||
rodata PT_LOAD FLAGS((1 << 2)) ; /* Read only */ | ||
data PT_LOAD FLAGS((1 << 1) | (1 << 2)) ; /* Write + Read */ | ||
} | ||
|
||
SECTIONS | ||
{ | ||
/* We wanna be placed in the topmost 2GiB of the address space, for optimisations */ | ||
/* and because that is what the stivale2 spec mandates. */ | ||
/* Any address in this region will do, but often 0xffffffff80000000 is chosen as */ | ||
/* that is the beginning of the region. */ | ||
. = 0xffffffff80000000; | ||
|
||
.text : { | ||
*(.text .text.*) | ||
} :text | ||
|
||
/* Move to the next memory page for .rodata */ | ||
. += CONSTANT(MAXPAGESIZE); | ||
|
||
/* We place the .stivale2hdr section containing the header in its own section, */ | ||
/* and we use the KEEP directive on it to make sure it doesn't get discarded. */ | ||
.stivale2hdr : { | ||
KEEP(*(.stivale2hdr)) | ||
} :rodata | ||
|
||
.rodata : { | ||
*(.rodata .rodata.*) | ||
} :rodata | ||
|
||
/* Move to the next memory page for .data */ | ||
. += CONSTANT(MAXPAGESIZE); | ||
|
||
.data : { | ||
*(.data .data.*) | ||
} :data | ||
|
||
.bss : { | ||
*(COMMON) | ||
*(.bss .bss.*) | ||
} :data | ||
}</code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.