Added support for GNU Linker Script (#3373)
This commit is contained in:
parent
1b1d6731ff
commit
33f2cf9510
File diff suppressed because one or more lines are too long
|
@ -507,6 +507,11 @@
|
|||
"alias": "gni",
|
||||
"owner": "RunDevelopment"
|
||||
},
|
||||
"linker-script": {
|
||||
"title": "GNU Linker Script",
|
||||
"alias": "ld",
|
||||
"owner": "RunDevelopment"
|
||||
},
|
||||
"go": {
|
||||
"title": "Go",
|
||||
"require": "clike",
|
||||
|
|
|
@ -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'];
|
|
@ -0,0 +1 @@
|
|||
Prism.languages["linker-script"]={comment:{pattern:/(^|\s)\/\*[\s\S]*?(?:$|\*\/)/,lookbehind:!0,greedy:!0},identifier:{pattern:/"[^"\r\n]*"/,greedy:!0},"location-counter":{pattern:/\B\.\B/,alias:"important"},section:{pattern:/(^|[^\w*])\.\w+\b/,lookbehind:!0,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"];
|
|
@ -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>
|
|
@ -199,6 +199,7 @@
|
|||
"gamemakerlanguage": "gml",
|
||||
"po": "gettext",
|
||||
"gni": "gn",
|
||||
"ld": "linker-script",
|
||||
"go-mod": "go-module",
|
||||
"hbs": "handlebars",
|
||||
"hs": "haskell",
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -102,6 +102,8 @@
|
|||
"glsl": "GLSL",
|
||||
"gn": "GN",
|
||||
"gni": "GN",
|
||||
"linker-script": "GNU Linker Script",
|
||||
"ld": "GNU Linker Script",
|
||||
"go-module": "Go module",
|
||||
"go-mod": "Go module",
|
||||
"graphql": "GraphQL",
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,11 @@
|
|||
/**/
|
||||
/*
|
||||
comment
|
||||
*/
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["comment", "/**/"],
|
||||
["comment", "/*\r\ncomment\r\n*/"]
|
||||
]
|
|
@ -0,0 +1,22 @@
|
|||
MAX (SIZEOF (.text0), SIZEOF (.text1))
|
||||
|
||||
FOO()
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["function", "MAX"],
|
||||
["punctuation", "("],
|
||||
["function", "SIZEOF"],
|
||||
["punctuation", "("],
|
||||
["section", ".text0"],
|
||||
["punctuation", ")"],
|
||||
["punctuation", ","],
|
||||
["function", "SIZEOF"],
|
||||
["punctuation", "("],
|
||||
["section", ".text1"],
|
||||
["punctuation", ")"],
|
||||
["punctuation", ")"],
|
||||
|
||||
["function", "FOO"], ["punctuation", "("], ["punctuation", ")"]
|
||||
]
|
|
@ -0,0 +1,24 @@
|
|||
"SECTION" = 9;
|
||||
"with a space" = "also with a space" + 10;
|
||||
_fourk_1 = 4K;
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["identifier", "\"SECTION\""],
|
||||
["operator", "="],
|
||||
["number", "9"],
|
||||
["punctuation", ";"],
|
||||
|
||||
["identifier", "\"with a space\""],
|
||||
["operator", "="],
|
||||
["identifier", "\"also with a space\""],
|
||||
["operator", "+"],
|
||||
["number", "10"],
|
||||
["punctuation", ";"],
|
||||
|
||||
"\r\n_fourk_1 ",
|
||||
["operator", "="],
|
||||
["number", "4K"],
|
||||
["punctuation", ";"]
|
||||
]
|
|
@ -0,0 +1,58 @@
|
|||
SECTIONS
|
||||
{
|
||||
output :
|
||||
{
|
||||
file1(.text)
|
||||
. = . + 1000;
|
||||
file2(.text)
|
||||
. += 1000;
|
||||
file3(.text)
|
||||
} = 0x1234;
|
||||
}
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
"SECTIONS\r\n",
|
||||
|
||||
["punctuation", "{"],
|
||||
|
||||
"\r\n output ",
|
||||
["operator", ":"],
|
||||
|
||||
["punctuation", "{"],
|
||||
|
||||
"\r\n file1",
|
||||
["punctuation", "("],
|
||||
["section", ".text"],
|
||||
["punctuation", ")"],
|
||||
|
||||
["location-counter", "."],
|
||||
["operator", "="],
|
||||
["location-counter", "."],
|
||||
["operator", "+"],
|
||||
["number", "1000"],
|
||||
["punctuation", ";"],
|
||||
|
||||
"\r\n file2",
|
||||
["punctuation", "("],
|
||||
["section", ".text"],
|
||||
["punctuation", ")"],
|
||||
|
||||
["location-counter", "."],
|
||||
["operator", "+="],
|
||||
["number", "1000"],
|
||||
["punctuation", ";"],
|
||||
|
||||
"\r\n file3",
|
||||
["punctuation", "("],
|
||||
["section", ".text"],
|
||||
["punctuation", ")"],
|
||||
|
||||
["punctuation", "}"],
|
||||
["operator", "="],
|
||||
["number", "0x1234"],
|
||||
["punctuation", ";"],
|
||||
|
||||
["punctuation", "}"]
|
||||
]
|
|
@ -0,0 +1,27 @@
|
|||
0157255
|
||||
57001
|
||||
0xdead
|
||||
0x0123456789abcdefABCDEF
|
||||
|
||||
4K
|
||||
4096
|
||||
0x1000
|
||||
|
||||
1M
|
||||
0x100000000
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["number", "0157255"],
|
||||
["number", "57001"],
|
||||
["number", "0xdead"],
|
||||
["number", "0x0123456789abcdefABCDEF"],
|
||||
|
||||
["number", "4K"],
|
||||
["number", "4096"],
|
||||
["number", "0x1000"],
|
||||
|
||||
["number", "1M"],
|
||||
["number", "0x100000000"]
|
||||
]
|
|
@ -0,0 +1,57 @@
|
|||
+ - * / % -- ++
|
||||
>> <<
|
||||
~ & | ^
|
||||
+= -= *= /= %= >>= <<= &= |= ^=
|
||||
! && ||
|
||||
-> ::
|
||||
? :
|
||||
= == != < > <= >=
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["operator", "+"],
|
||||
["operator", "-"],
|
||||
["operator", "*"],
|
||||
["operator", "/"],
|
||||
["operator", "%"],
|
||||
["operator", "--"],
|
||||
["operator", "++"],
|
||||
|
||||
["operator", ">>"],
|
||||
["operator", "<<"],
|
||||
|
||||
["operator", "~"],
|
||||
["operator", "&"],
|
||||
["operator", "|"],
|
||||
["operator", "^"],
|
||||
|
||||
["operator", "+="],
|
||||
["operator", "-="],
|
||||
["operator", "*="],
|
||||
["operator", "/="],
|
||||
["operator", "%="],
|
||||
["operator", ">>="],
|
||||
["operator", "<<="],
|
||||
["operator", "&="],
|
||||
["operator", "|="],
|
||||
["operator", "^="],
|
||||
|
||||
["operator", "!"],
|
||||
["operator", "&&"],
|
||||
["operator", "||"],
|
||||
|
||||
["operator", "->"],
|
||||
["operator", "::"],
|
||||
|
||||
["operator", "?"],
|
||||
["operator", ":"],
|
||||
|
||||
["operator", "="],
|
||||
["operator", "=="],
|
||||
["operator", "!="],
|
||||
["operator", "<"],
|
||||
["operator", ">"],
|
||||
["operator", "<="],
|
||||
["operator", ">="]
|
||||
]
|
|
@ -0,0 +1,14 @@
|
|||
( ) { }
|
||||
; ,
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
|
||||
["punctuation", ";"],
|
||||
["punctuation", ","]
|
||||
]
|
|
@ -0,0 +1,11 @@
|
|||
.data
|
||||
.DATA
|
||||
.text
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["section", ".data"],
|
||||
["section", ".DATA"],
|
||||
["section", ".text"]
|
||||
]
|
Loading…
Reference in New Issue