as: handle .data section

This commit is contained in:
Mikael Pettersson
2019-12-30 16:57:56 +01:00
parent 6f966758eb
commit 896378c3b5
3 changed files with 45 additions and 1 deletions

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
/* 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

View File

@@ -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

View File

@@ -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};