From 896378c3b5c4917947224df8535c9245fc45d43d Mon Sep 17 00:00:00 2001 From: Mikael Pettersson Date: Mon, 30 Dec 2019 16:57:56 +0100 Subject: [PATCH] as: handle .data section --- erlang/apps/as/priv/test5.s | 36 +++++++++++++++++++++++++++++++++ erlang/apps/as/src/assemble.erl | 4 ++++ erlang/apps/as/src/input.erl | 6 +++++- 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 erlang/apps/as/priv/test5.s diff --git a/erlang/apps/as/priv/test5.s b/erlang/apps/as/priv/test5.s new file mode 100644 index 0000000..f60f268 --- /dev/null +++ b/erlang/apps/as/priv/test5.s @@ -0,0 +1,36 @@ +/* + * test5.s + * Copyright (C) 2019 Mikael Pettersson + * + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with pdp10-tools. If not, see . + */ + +/* test putting data in .text and code in .data */ + + .text + .globl foo + .type foo,@function +foo: + .long 0201040000033, 0263740000000 + .size foo,.-foo + + .data + .globl bar + .type bar,@function +bar: + movei 1,033 + popj 017, + .size bar,.-bar diff --git a/erlang/apps/as/src/assemble.erl b/erlang/apps/as/src/assemble.erl index 8e9bd76..d873a8b 100644 --- a/erlang/apps/as/src/assemble.erl +++ b/erlang/apps/as/src/assemble.erl @@ -40,6 +40,10 @@ sections([Section | Sections], Tunit) -> section(Section, Tunit) -> case Section of + #section{ name = ".data" ++ _ + , sh_type = ?SHT_PROGBITS + , sh_flags = ?SHF_ALLOC bor ?SHF_WRITE + } -> stmts(Section, Tunit); #section{ name = ".text" ++ _ , sh_type = ?SHT_PROGBITS , sh_flags = ?SHF_ALLOC bor ?SHF_EXECINSTR diff --git a/erlang/apps/as/src/input.erl b/erlang/apps/as/src/input.erl index e3eaee0..ada52af 100644 --- a/erlang/apps/as/src/input.erl +++ b/erlang/apps/as/src/input.erl @@ -286,7 +286,11 @@ pass2_sections([{SectionName, {Section, SubsectionsMap}} | Sections], Tunit0) -> {error, _Reason} = Error -> Error end. -pass2_subsections(_SectionName = ".text", SubsectionsMap, Tunit) -> +pass2_subsections(SectionName, SubsectionsMap, Tunit) -> + case SectionName of + ".data" ++ _ -> ok; + ".text" ++ _ -> ok + end, pass2_subsections(lists:sort(maps:to_list(SubsectionsMap)), Tunit). pass2_subsections([], Tunit) -> {ok, Tunit};