as: tunit: enable representing relocation sections

This commit is contained in:
Mikael Pettersson 2020-02-22 15:40:14 +01:00
parent c3d2e21dc1
commit de753f440b
3 changed files with 20 additions and 1 deletions

View File

@ -295,6 +295,7 @@ make_section(SectionName) ->
, sh_offset = 0
, sh_flags = 0
, sh_link = ?SHN_UNDEF
, sh_info = 0
, sh_addralign = 0
, sh_entsize = 0
}.
@ -664,6 +665,7 @@ section_dot_comment() -> % ".comment"
, sh_offset = 0
, sh_flags = ?SHF_MERGE bor ?SHF_STRINGS
, sh_link = ?SHN_UNDEF
, sh_info = 0
, sh_addralign = 1
, sh_entsize = 1
}.
@ -678,6 +680,7 @@ section_dot_data() -> % ".data"
, sh_offset = 0
, sh_flags = ?SHF_ALLOC bor ?SHF_WRITE
, sh_link = ?SHN_UNDEF
, sh_info = 0
, sh_addralign = 4 % FIXME: target-specific
, sh_entsize = 0
}.
@ -692,6 +695,7 @@ section_dot_rodata() -> % ".rodata"
, sh_offset = 0
, sh_flags = ?SHF_ALLOC
, sh_link = ?SHN_UNDEF
, sh_info = 0
, sh_addralign = 4 % FIXME: target-specific
, sh_entsize = 0
}.
@ -706,6 +710,7 @@ section_dot_text() -> % ".text"
, sh_offset = 0
, sh_flags = ?SHF_ALLOC bor ?SHF_EXECINSTR
, sh_link = ?SHN_UNDEF
, sh_info = 0
, sh_addralign = 4 % FIXME: target-specific
, sh_entsize = 0
}.

View File

@ -162,6 +162,7 @@ create_strtab(Context) ->
, sh_type = ?SHT_STRTAB
, sh_flags = ?SHF_MERGE bor ?SHF_STRINGS % FIXME: check
, sh_link = ?SHN_UNDEF
, sh_info = 0
, sh_addralign = 1 % FIXME: check
, sh_entsize = 1 % FIXME: check
},
@ -187,6 +188,7 @@ create_symtab(Context) ->
, sh_type = ?SHT_SYMTAB
, sh_flags = 0
, sh_link = StrTabShndx
, sh_info = 0
, sh_addralign = 4 % FIXME: check
, sh_entsize = ?ELF36_SYM_SIZEOF
},
@ -282,6 +284,7 @@ create_shstrtab(Context) ->
, sh_type = ?SHT_STRTAB
, sh_flags = ?SHF_MERGE bor ?SHF_STRINGS % FIXME: check
, sh_link = ?SHN_UNDEF
, sh_info = 0
, sh_addralign = 1 % FIXME: check
, sh_entsize = 1 % FIXME: check
},
@ -426,6 +429,7 @@ emit_shdr(Section, FP, Offset) ->
, sh_offset = ShOffset
, sh_flags = ShFlags
, sh_link = ShLink
, sh_info = ShInfo
, sh_addralign = ShAddrAlign
, sh_entsize = ShEntSize
} = Section,
@ -437,7 +441,7 @@ emit_shdr(Section, FP, Offset) ->
, sh_offset = ShOffset
, sh_size = Dot
, sh_link = ShLink
, sh_info = 0 % FIXME: for symtab, LAST_LOCAL + 1
, sh_info = ShInfo % FIXME: for symtab, LAST_LOCAL + 1
, sh_addralign = ShAddrAlign
, sh_entsize = ShEntSize
},

View File

@ -127,12 +127,21 @@
-type tbyte() :: 0..511. % may contain octets or nonets
-type image() :: tbyte() | [image()].
%% Relocations.
-record(rela, { offset :: non_neg_integer()
, type :: byte() % ?R_PDP10_*
, symbol :: string()
, addend :: integer()
}).
%% Sections accumulate code or data, and define symbols.
-record(section,
{ name :: string()
, data :: {stmts, [stmt()]} % before assembly, in reverse
| {image, image()} % after assembly
| {relocs, string(), [#rela{}]} % after assembly
, dot :: non_neg_integer()
, shndx :: non_neg_integer() % assigned during output
%% FIXME: should contain an #elf36_Shdr{} here instead
@ -141,6 +150,7 @@
, sh_offset :: non_neg_integer() % assigned during output
, sh_flags :: non_neg_integer()
, sh_link :: non_neg_integer() % assigned during output
, sh_info :: non_neg_integer() % assigned during output
, sh_addralign :: non_neg_integer()
, sh_entsize :: non_neg_integer()
}).