Convert consecutive FSF copyright years to ranges.
[bpt/emacs.git] / lisp / progmodes / ld-script.el
CommitLineData
98971e75
MY
1;;; ld-script.el --- GNU linker script editing mode for Emacs
2
73b0cd50 3;; Copyright (C) 2001-2011 Free Software Foundation, Inc.
98971e75
MY
4
5;; Author: Masatake YAMATO<jet@gyve.org>
6;; Keywords: languages, faces
7
b8313039
JPW
8;; This file is part of GNU Emacs.
9
b1fc2b50 10;; GNU Emacs is free software: you can redistribute it and/or modify
98971e75 11;; it under the terms of the GNU General Public License as published by
b1fc2b50
GM
12;; the Free Software Foundation, either version 3 of the License, or
13;; (at your option) any later version.
98971e75 14
b1fc2b50 15;; GNU Emacs is distributed in the hope that it will be useful,
98971e75
MY
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
b1fc2b50 21;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
98971e75 22
b8313039
JPW
23;;; Commentary:
24
25;; Major mode for editing GNU linker (ld) scripts.
26
27;;; Code:
98971e75
MY
28
29;; Custom
30(defgroup ld-script nil
31 "GNU linker script code editing commands for Emacs."
32 :prefix "ld-script-"
33 :group 'languages)
34
a5d37031
MB
35(defvar ld-script-location-counter-face 'ld-script-location-counter)
36(defface ld-script-location-counter
4c344753 37 '((t :weight bold :inherit font-lock-builtin-face))
98971e75
MY
38 "Face for location counter in GNU ld script."
39 :group 'ld-script)
40
41;; Syntax rules
b8313039 42(defvar ld-script-mode-syntax-table
98971e75
MY
43 (let ((st (make-syntax-table)))
44 (modify-syntax-entry ?\ "-" st)
45 (modify-syntax-entry ?{ "(}" st)
46 (modify-syntax-entry ?} "){" st)
47 (modify-syntax-entry ?\( "()" st)
48 (modify-syntax-entry ?\) ")(" st)
49 (modify-syntax-entry ?\[ "(]" st)
50 (modify-syntax-entry ?\] ")[" st)
51 (modify-syntax-entry ?_ "w" st)
52 (modify-syntax-entry ?. "_" st)
53 (modify-syntax-entry ?\\ "\\" st)
54 (modify-syntax-entry ?: "." st)
55 (modify-syntax-entry ?, "." st)
56 (modify-syntax-entry ?? "." st)
57 (modify-syntax-entry ?= "." st)
58 (modify-syntax-entry ?* ". 23" st)
59 (modify-syntax-entry ?/ ". 14" st)
60 (modify-syntax-entry ?+ "." st)
61 (modify-syntax-entry ?- "." st)
62 (modify-syntax-entry ?! "." st)
63 (modify-syntax-entry ?~ "." st)
64 (modify-syntax-entry ?% "." st)
65 (modify-syntax-entry ?< "." st)
66 (modify-syntax-entry ?> "." st)
67 (modify-syntax-entry ?& "." st)
68 (modify-syntax-entry ?| "." st)
69 (modify-syntax-entry ?\" "\"" st)
70 st)
71 "Syntax table used while in `ld-script-mode'.")
72
73;; Font lock keywords
75ee40be 74;; (The section number comes from ld's info.)
b8313039 75(defvar ld-script-keywords
75ee40be
MY
76 '(
77 ;; 3.4.1 Setting the Entry Point
ce009d0b 78 "ENTRY"
75ee40be
MY
79 ;; 3.4.2 Commands Dealing with Files
80 "INCLUDE" "INPUT" "GROUP" "AS_NEEDED" "OUTPUT" "SEARCH_DIR" "STARTUP"
81 ;; 3.4.3 Commands Dealing with Object File Formats
98971e75 82 "OUTPUT_FORMAT" "TARGET"
75ee40be 83 ;; 3.4.3 Other Linker Script Commands
ce009d0b 84 "ASSERT" "EXTERN" "FORCE_COMMON_ALLOCATION"
75ee40be
MY
85 "INHIBIT_COMMON_ALLOCATION" "NOCROSSREFS" "OUTPUT_ARCH"
86 ;; 3.5.2 PROVIDE
b8313039 87 "PROVIDE"
75ee40be 88 ;; 3.5.3 PROVIDE_HIDDEN
5bc1b111 89 "PROVIDE_HIDDEN"
75ee40be 90 ;; 3.6 SECTIONS Command
ce009d0b 91 "SECTIONS"
75ee40be
MY
92 ;; 3.6.4.2 Input Section Wildcard Patterns
93 "SORT" "SORT_BY_NAME" "SORT_BY_ALIGNMENT"
94 ;; 3.6.4.3 Input Section for Common Symbols
95 "COMMON"
96 ;; 3.6.4.4 Input Section and Garbage Collection
97 "KEEP"
98 ;; 3.6.5 Output Section Data
99 "BYTE" "SHORT" "LONG" "QUAD" "SQUAD" "FILL"
100 ;; 3.6.6 Output Section Keywords
101 "CREATE_OBJECT_SYMBOLS" "CONSTRUCTORS"
102 "__CTOR_LIST__" "__CTOR_END__" "__DTOR_LIST__" "__DTOR_END__"
103 ;; 3.6.7 Output Section Discarding
104 ;; See `ld-script-font-lock-keywords'
105 ;; 3.6.8.1 Output Section Type
98971e75 106 "NOLOAD" "DSECT" "COPY" "INFO" "OVERLAY"
75ee40be 107 ;; 3.6.8.2 Output Section LMA
98971e75 108 "AT"
75ee40be
MY
109 ;; 3.6.8.4 Forced Input Alignment
110 "SUBALIGN"
111 ;; 3.6.8.6 Output Section Phdr
112 ":PHDR"
113 ;; 3.7 MEMORY Command
98971e75 114 "MEMORY"
75ee40be 115 ;; 3.8 PHDRS Command
98971e75
MY
116 "PHDRS" "FILEHDR" "FLAGS"
117 "PT_NULL" "PT_LOAD" "PT_DYNAMIC" "PT_INTERP" "PT_NONE" "PT_SHLIB" "PT_PHDR"
75ee40be 118 ;; 3.9 VERSION Command
98971e75
MY
119 "VERSION")
120 "Keywords used of GNU ld script.")
121
75ee40be 122;; 3.10.8 Builtin Functions
b8313039
JPW
123(defvar ld-script-builtins
124 '("ABSOLUTE"
98971e75
MY
125 "ADDR"
126 "ALIGN"
127 "BLOCK"
6f9a47ab
MY
128 "DATA_SEGMENT_ALIGN"
129 "DATA_SEGMENT_END"
130 "DATA_SEGMENT_RELRO_END"
98971e75 131 "DEFINED"
75ee40be 132 "LENGTH" "len" "l"
98971e75
MY
133 "LOADADDR"
134 "MAX"
135 "MIN"
136 "NEXT"
75ee40be 137 "ORIGIN" "org" "o"
6f9a47ab 138 "SEGMENT_START"
98971e75
MY
139 "SIZEOF"
140 "SIZEOF_HEADERS"
141 "sizeof_headers")
142 "Builtin functions of GNU ld script.")
143
144(defvar ld-script-font-lock-keywords
4076cbf6
MY
145 (append
146 `((,(regexp-opt ld-script-keywords 'words)
147 1 font-lock-keyword-face)
148 (,(regexp-opt ld-script-builtins 'words)
149 1 font-lock-builtin-face)
75ee40be
MY
150 ;; 3.6.7 Output Section Discarding
151 ;; 3.6.4.1 Input Section Basics
152 ;; 3.6.8.6 Output Section Phdr
153 ("/DISCARD/\\|EXCLUDE_FILE\\|:NONE" . font-lock-warning-face)
4076cbf6
MY
154 ("\\W\\(\\.\\)\\W" 1 ld-script-location-counter-face)
155 )
156 cpp-font-lock-keywords)
b8313039 157 "Default font-lock-keywords for `ld-script-mode'.")
98971e75 158
98971e75
MY
159;;;###autoload
160(define-derived-mode ld-script-mode nil "LD-Script"
161 "A major mode to edit GNU ld script files"
162 (set (make-local-variable 'comment-start) "/* ")
163 (set (make-local-variable 'comment-end) " */")
4c344753
SM
164 (set (make-local-variable 'font-lock-defaults)
165 '(ld-script-font-lock-keywords nil)))
98971e75 166
b8313039
JPW
167(provide 'ld-script)
168
98971e75 169;;; ld-script.el ends here