mescc: Support -nodefaultlibs, -nostartfiles, -nostdlib.
* module/mescc.scm (parse-opts): Parse -nodefaultlibs, -nostartfiles, -nostdlib. * module/mescc/mescc.scm (mescc:link): Handle -nodefaultlibs, -nostdlib. (hex2->elf): Handle -nostartfiles, -nostdlib.
This commit is contained in:
parent
d0e6228fa1
commit
4fc1f5444a
|
@ -58,12 +58,15 @@
|
||||||
(compile (single-char #\S))
|
(compile (single-char #\S))
|
||||||
(define (single-char #\D) (value #t))
|
(define (single-char #\D) (value #t))
|
||||||
(debug-info (single-char #\g))
|
(debug-info (single-char #\g))
|
||||||
(dumpmachine (single-char #\d))
|
(dumpmachine)
|
||||||
(help (single-char #\h))
|
(help (single-char #\h))
|
||||||
(include (single-char #\I) (value #t))
|
(include (single-char #\I) (value #t))
|
||||||
(library-dir (single-char #\L) (value #t))
|
(library-dir (single-char #\L) (value #t))
|
||||||
(library (single-char #\l) (value #t))
|
(library (single-char #\l) (value #t))
|
||||||
(machine (single-char #\m) (value #t))
|
(machine (single-char #\m) (value #t))
|
||||||
|
(nodefaultlibs)
|
||||||
|
(nostartfiles)
|
||||||
|
(nostdlib)
|
||||||
(preprocess (single-char #\E))
|
(preprocess (single-char #\E))
|
||||||
(std (value #t))
|
(std (value #t))
|
||||||
(output (single-char #\o) (value #t))
|
(output (single-char #\o) (value #t))
|
||||||
|
@ -97,6 +100,9 @@ Usage: mescc [OPTION]... FILE...
|
||||||
-L DIR append DIR to library path
|
-L DIR append DIR to library path
|
||||||
-l LIBNAME link with LIBNAME
|
-l LIBNAME link with LIBNAME
|
||||||
-m BITS compile for BITS bits [32]
|
-m BITS compile for BITS bits [32]
|
||||||
|
-nodefaultlibs do not use libc.o when linking
|
||||||
|
-nostartfiles do not use crt1.o when linking
|
||||||
|
-nostdlib do not use crt1.o or libc.o when linking
|
||||||
-o FILE write output to FILE
|
-o FILE write output to FILE
|
||||||
-O LEVEL use optimizing LEVEL
|
-O LEVEL use optimizing LEVEL
|
||||||
-S preprocess and compile only; do not assemble or link
|
-S preprocess and compile only; do not assemble or link
|
||||||
|
@ -119,7 +125,11 @@ General help using GNU software: <http://gnu.org/gethelp/>
|
||||||
options))))
|
options))))
|
||||||
|
|
||||||
(define (mescc:main args)
|
(define (mescc:main args)
|
||||||
(let* ((single-dash-options '("-dumpmachine" "-std"))
|
(let* ((single-dash-options '("-dumpmachine"
|
||||||
|
"-nodefaultlibs"
|
||||||
|
"-nostartfiles"
|
||||||
|
"-nostdlib"
|
||||||
|
"-std"))
|
||||||
(args (map (lambda (o)
|
(args (map (lambda (o)
|
||||||
(if (member o single-dash-options) (string-append "-" o)
|
(if (member o single-dash-options) (string-append "-" o)
|
||||||
o))
|
o))
|
||||||
|
|
|
@ -135,9 +135,11 @@
|
||||||
(hex2-files (if (null? infos) hex2-files
|
(hex2-files (if (null? infos) hex2-files
|
||||||
(append hex2-files
|
(append hex2-files
|
||||||
(list (infos->hex2 options hex2-file-name infos)))))
|
(list (infos->hex2 options hex2-file-name infos)))))
|
||||||
|
(default-libraries (if (or (option-ref options 'nodefaultlibs #f)
|
||||||
|
(option-ref options 'nostdlib #f)) '()
|
||||||
|
'("c")))
|
||||||
(libraries (filter-map (multi-opt 'library) options))
|
(libraries (filter-map (multi-opt 'library) options))
|
||||||
(libraries (if (pair? libraries) libraries '("c")))
|
(libraries (delete-duplicates (append libraries default-libraries)))
|
||||||
(libraries (if (equal? libraries '("none")) '() libraries))
|
|
||||||
(hex2-libraries (map (cut find-library options ".o" <>) libraries))
|
(hex2-libraries (map (cut find-library options ".o" <>) libraries))
|
||||||
(hex2-files (append hex2-files hex2-libraries))
|
(hex2-files (append hex2-files hex2-libraries))
|
||||||
(S-files (append S-files (map (cut find-library options ".S" <>) libraries)))
|
(S-files (append S-files (map (cut find-library options ".S" <>) libraries)))
|
||||||
|
@ -208,12 +210,15 @@
|
||||||
(elf-footer (or elf-footer
|
(elf-footer (or elf-footer
|
||||||
(arch-find options (string-append
|
(arch-find options (string-append
|
||||||
"elf" machine "-footer-single-main.hex2"))))
|
"elf" machine "-footer-single-main.hex2"))))
|
||||||
|
(start-files (if (or (option-ref options 'nostartfiles #f)
|
||||||
|
(option-ref options 'nostdlib #f)) '()
|
||||||
|
`("-f" ,(arch-find options "crt1.o"))))
|
||||||
(command `(,hex2
|
(command `(,hex2
|
||||||
"--LittleEndian"
|
"--LittleEndian"
|
||||||
"--Architecture" ,architecture
|
"--Architecture" ,architecture
|
||||||
"--BaseAddress" ,base-address
|
"--BaseAddress" ,base-address
|
||||||
"-f" ,(arch-find options (string-append "elf" machine "-header.hex2"))
|
"-f" ,(arch-find options (string-append "elf" machine "-header.hex2"))
|
||||||
"-f" ,(arch-find options "crt1.o")
|
,@start-files
|
||||||
,@(append-map (cut list "-f" <>) hex2-files)
|
,@(append-map (cut list "-f" <>) hex2-files)
|
||||||
"-f" ,elf-footer
|
"-f" ,elf-footer
|
||||||
"--exec_enable"
|
"--exec_enable"
|
||||||
|
|
Loading…
Reference in New Issue