mirror of
https://github.com/mikpe/pdp10-tools.git
synced 2026-04-13 23:44:03 +00:00
as: handle the .rodata section
This commit is contained in:
29
erlang/apps/as/priv/test7.s
Normal file
29
erlang/apps/as/priv/test7.s
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* test7.s
|
||||
* Copyright (C) 2020 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/>.
|
||||
*/
|
||||
|
||||
.section .text,"ax",@progbits
|
||||
.globl foo
|
||||
.type foo,@function
|
||||
foo:
|
||||
popj 017,
|
||||
.size foo,.-foo
|
||||
|
||||
.section .rodata,"a",@progbits
|
||||
bar: .long 42
|
||||
@@ -1,7 +1,7 @@
|
||||
%%% -*- erlang-indent-level: 2 -*-
|
||||
%%%
|
||||
%%% sections assembler for pdp10-elf as
|
||||
%%% Copyright (C) 2013-2019 Mikael Pettersson
|
||||
%%% Copyright (C) 2013-2020 Mikael Pettersson
|
||||
%%%
|
||||
%%% This file is part of pdp10-tools.
|
||||
%%%
|
||||
@@ -44,6 +44,10 @@ section(Section, Tunit) ->
|
||||
, sh_type = ?SHT_PROGBITS
|
||||
, sh_flags = ?SHF_ALLOC bor ?SHF_WRITE
|
||||
} -> stmts(Section, Tunit);
|
||||
#section{ name = ".rodata" ++ _
|
||||
, sh_type = ?SHT_PROGBITS
|
||||
, sh_flags = ?SHF_ALLOC
|
||||
} -> stmts(Section, Tunit);
|
||||
#section{ name = ".text" ++ _
|
||||
, sh_type = ?SHT_PROGBITS
|
||||
, sh_flags = ?SHF_ALLOC bor ?SHF_EXECINSTR
|
||||
|
||||
@@ -404,6 +404,7 @@ pass2_sections([{SectionName, {Section, SubsectionsMap}} | Sections], Tunit0) ->
|
||||
pass2_subsections(SectionName, SubsectionsMap, Tunit) ->
|
||||
case SectionName of
|
||||
".data" ++ _ -> ok;
|
||||
".rodata" ++ _ -> ok;
|
||||
".text" ++ _ -> ok
|
||||
end,
|
||||
pass2_subsections(lists:sort(maps:to_list(SubsectionsMap)), Tunit).
|
||||
@@ -648,6 +649,7 @@ tunit_init() ->
|
||||
section_from_name(SectionName) ->
|
||||
case SectionName of
|
||||
".data" -> section_dot_data();
|
||||
".rodata" -> section_dot_rodata();
|
||||
".text" -> section_dot_text();
|
||||
_ -> false
|
||||
end.
|
||||
@@ -680,6 +682,20 @@ section_dot_data() -> % ".data"
|
||||
, sh_entsize = 0
|
||||
}.
|
||||
|
||||
section_dot_rodata() -> % ".rodata"
|
||||
#section{ name = ".rodata"
|
||||
, data = {stmts, []}
|
||||
, dot = 0
|
||||
, shndx = 0
|
||||
, sh_name = 0
|
||||
, sh_type = ?SHT_PROGBITS
|
||||
, sh_offset = 0
|
||||
, sh_flags = ?SHF_ALLOC
|
||||
, sh_link = ?SHN_UNDEF
|
||||
, sh_addralign = 4 % FIXME: target-specific
|
||||
, sh_entsize = 0
|
||||
}.
|
||||
|
||||
section_dot_text() -> % ".text"
|
||||
#section{ name = ".text"
|
||||
, data = {stmts, []}
|
||||
|
||||
Reference in New Issue
Block a user