Commit | Line | Data |
---|---|---|
98971e75 MY |
1 | ;;; ld-script.el --- GNU linker script editing mode for Emacs |
2 | ||
3 | ;; Copyright (C) 2003 Free Software Foundation, Inc. | |
4 | ||
5 | ;; Author: Masatake YAMATO<jet@gyve.org> | |
6 | ;; Keywords: languages, faces | |
7 | ||
8 | ;; This program is free software; you can redistribute it and/or modify | |
9 | ;; it under the terms of the GNU General Public License as published by | |
10 | ;; the Free Software Foundation; either version 2, or (at your option) | |
11 | ;; any later version. | |
12 | ||
13 | ;; This program is distributed in the hope that it will be useful, | |
14 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | ;; GNU General Public License for more details. | |
17 | ||
18 | ;; You should have received a copy of the GNU General Public License | |
19 | ;; along with this program; see the file COPYING. If not, write to the | |
20 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
21 | ;; Boston, MA 02111-1307, USA. | |
22 | ||
23 | ;;; Codes: | |
24 | ||
25 | ;; Custom | |
26 | (defgroup ld-script nil | |
27 | "GNU linker script code editing commands for Emacs." | |
28 | :prefix "ld-script-" | |
29 | :group 'languages) | |
30 | ||
31 | (defvar ld-script-location-counter-face 'ld-script-location-counter-face) | |
32 | (defface ld-script-location-counter-face | |
33 | '((t (:weight bold :inherit font-lock-builtin-face))) | |
34 | "Face for location counter in GNU ld script." | |
35 | :group 'ld-script) | |
36 | ||
37 | ;; Syntax rules | |
38 | (defvar ld-script-mode-syntax-table | |
39 | (let ((st (make-syntax-table))) | |
40 | (modify-syntax-entry ?\ "-" st) | |
41 | (modify-syntax-entry ?{ "(}" st) | |
42 | (modify-syntax-entry ?} "){" st) | |
43 | (modify-syntax-entry ?\( "()" st) | |
44 | (modify-syntax-entry ?\) ")(" st) | |
45 | (modify-syntax-entry ?\[ "(]" st) | |
46 | (modify-syntax-entry ?\] ")[" st) | |
47 | (modify-syntax-entry ?_ "w" st) | |
48 | (modify-syntax-entry ?. "_" st) | |
49 | (modify-syntax-entry ?\\ "\\" st) | |
50 | (modify-syntax-entry ?: "." st) | |
51 | (modify-syntax-entry ?, "." st) | |
52 | (modify-syntax-entry ?? "." st) | |
53 | (modify-syntax-entry ?= "." st) | |
54 | (modify-syntax-entry ?* ". 23" st) | |
55 | (modify-syntax-entry ?/ ". 14" st) | |
56 | (modify-syntax-entry ?+ "." st) | |
57 | (modify-syntax-entry ?- "." st) | |
58 | (modify-syntax-entry ?! "." st) | |
59 | (modify-syntax-entry ?~ "." 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 | st) | |
67 | "Syntax table used while in `ld-script-mode'.") | |
68 | ||
69 | ;; Font lock keywords | |
70 | (defvar ld-script-keywords | |
71 | '("ENTRY" "INCLUDE" "INPUT" "GROUP" | |
72 | "OUTPUT" "SEARCH_DIR" "STARTUP" | |
73 | "OUTPUT_FORMAT" "TARGET" | |
74 | "ASSERT" "EXTERN" "FORCE_COMMON_ALLOCATION" "NOCROSSREFS" "OUTPUT_ARCH" | |
75 | "PROVIDE" | |
76 | "SECTIONS" "SORT" "COMMON" "KEEP" | |
77 | "BYTE" "SHORT" "LONG" "QUAD" "SQAD" | |
78 | "FILL" | |
79 | "CREATE_OBJECT_SYMBOLS" | |
80 | "CONSTRUCTORS" | |
81 | "NOLOAD" "DSECT" "COPY" "INFO" "OVERLAY" | |
82 | "AT" | |
83 | "MEMORY" | |
84 | "PHDRS" "FILEHDR" "FLAGS" | |
85 | "PT_NULL" "PT_LOAD" "PT_DYNAMIC" "PT_INTERP" "PT_NONE" "PT_SHLIB" "PT_PHDR" | |
86 | "VERSION") | |
87 | "Keywords used of GNU ld script.") | |
88 | ||
89 | (defvar ld-script-builtins | |
90 | '("ABSOLUTE" | |
91 | "ADDR" | |
92 | "ALIGN" | |
93 | "BLOCK" | |
94 | "DEFINED" | |
95 | "LOADADDR" | |
96 | "MAX" | |
97 | "MIN" | |
98 | "NEXT" | |
99 | "SIZEOF" | |
100 | "SIZEOF_HEADERS" | |
101 | "sizeof_headers") | |
102 | "Builtin functions of GNU ld script.") | |
103 | ||
104 | (defvar ld-script-font-lock-keywords | |
105 | `((,(regexp-opt ld-script-keywords 'words) | |
106 | 1 font-lock-keyword-face) | |
107 | (,(regexp-opt ld-script-builtins 'words) | |
108 | 1 font-lock-builtin-face) | |
109 | ("/DISCARD/" . font-lock-warning-face) | |
110 | ("##\\|#[^#\n]+$" . font-lock-preprocessor-face) | |
111 | ("\\W\\(\\.\\)\\W" 1 ld-script-location-counter-face) | |
112 | ) | |
113 | "Default font-lock-keywords for `ld-script mode'.") | |
114 | ||
115 | ;;;###autoload | |
116 | (add-to-list 'auto-mode-alist '("\\.lds" . ld-script-mode)) | |
117 | ||
118 | ;;;###autoload | |
119 | (define-derived-mode ld-script-mode nil "LD-Script" | |
120 | "A major mode to edit GNU ld script files" | |
121 | (set (make-local-variable 'comment-start) "/* ") | |
122 | (set (make-local-variable 'comment-end) " */") | |
123 | (set (make-local-variable 'indent-line-function) #'indent-relative) | |
124 | (set (make-local-variable 'font-lock-defaults) '(ld-script-font-lock-keywords nil))) | |
125 | ||
ab5796a9 | 126 | ;;; arch-tag: 83280b6b-e6fc-4d00-a630-922d7aec5593 |
98971e75 | 127 | ;;; ld-script.el ends here |