diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 614fc88..dd1dc68 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -33,16 +33,6 @@ jobs: clang --version gcc --version - - name: Cache Racket packages - uses: actions/cache@v4 - with: - path: | - ~/.racket - ~/.cache/racket - ~/.local/share/racket - ~/Library/Caches/Racket - key: racket-${{ matrix.racket-variant }}-${{ matrix.racket-version }}-${{ matrix.os }} - - name: Install a86 package run: | raco pkg install --no-docs ../a86/ diff --git a/a86/info.rkt b/a86/info.rkt index 0f55389..22c01dc 100644 --- a/a86/info.rkt +++ b/a86/info.rkt @@ -4,5 +4,6 @@ (define deps (list "base" "rackunit" "redex-lib" "redex-gui-lib")) (define scribblings '(("scribblings/a86.scrbl"))) (define test-omit-paths '("scribblings/" - "test/expressions.rkt")) + "test/expressions.rkt" + "test/sections.rkt")) (define pre-install-collection "check-x86.rkt") diff --git a/a86/printer.rkt b/a86/printer.rkt index 5dbb632..fe28851 100644 --- a/a86/printer.rkt +++ b/a86/printer.rkt @@ -4,11 +4,15 @@ [asm-string (-> (listof instruction?) string?)] ; deprecated [asm-display (-> (listof instruction?) any)]) +(define current-os + (make-parameter (system-type 'os))) + (define current-shared? (make-parameter #f)) (module* private #f - (provide current-shared?)) + (provide current-shared?) + (provide current-os)) ;; Asm -> String (define (asm-string a) @@ -26,14 +30,12 @@ ;; Label -> String ;; prefix with _ for Mac -(define label-symbol->string - (match (system-type 'os) +(define (label-symbol->string s) + (match (current-os) ['macosx - (λ (s) - (string-append "_" (symbol->string s)))] + (string-append "\"_" (symbol->string s) "\"")] [_ - (λ (s) - (symbol->string s))])) + (string-append "\"" (symbol->string s) "\"")])) ;(if (and (current-shared?) (memq s (current-extern-labels))) ; hack for ELF64 shared libraries in service of @@ -41,14 +43,7 @@ ;(string-append "$" (symbol->string s) " wrt ..plt") ;(symbol->string s)))])) -(define extern-label-decl-symbol->string - (match (system-type 'os) - ['macosx - (λ (s) - (string-append "_" (symbol->string s)))] - [_ - (λ (s) - (symbol->string s))])) +(define extern-label-decl-symbol->string label-symbol->string) ;; Instruction -> String (define (common-instruction->string i) @@ -187,12 +182,12 @@ (string-append "(" (exp->string e1) " " (symbol->string o) " " (exp->string e2) ")")])) (define (text-section n) - (match (system-type 'os) - ['macosx (format ".section __TEXT,~a\n\t.p2align 4" n)] + (match (current-os) + ['macosx (format ".section __TEXT,~a" n)] [_ (format ".section ~a,\"ax\",@progbits\n\t.p2align 4" n)])) (define (data-section n) - (match (system-type 'os) + (match (current-os) ['macosx (format ".section __DATA,~a\n\t.p2align 3" n)] [_ (format ".section ~a,\"aw\",@progbits\n\t.p2align 3" n)])) @@ -207,7 +202,7 @@ [(Global ($ l)) (string-append tab ".global " (label-symbol->string l))] [(Label ($ l)) (string-append (label-symbol->string l) ":")] [(Align n) - (match (system-type 'os) + (match (current-os) ['macosx (string-append ".p2align " (number->string (let loop ([i 0] [n n])