From 9d646d5fe8bb90a91cc9bb910273777a8ce009ca Mon Sep 17 00:00:00 2001 From: Mikael Pettersson Date: Sun, 16 Feb 2020 18:07:17 +0100 Subject: [PATCH] as: correct handling of ABS symbols --- erlang/apps/as/src/input.erl | 2 +- erlang/apps/as/src/output.erl | 9 ++++++--- erlang/apps/as/src/tunit.hrl | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/erlang/apps/as/src/input.erl b/erlang/apps/as/src/input.erl index 11943a2..dc34abb 100644 --- a/erlang/apps/as/src/input.erl +++ b/erlang/apps/as/src/input.erl @@ -465,7 +465,7 @@ dot_byte(Location, Tunit, #s_dot_byte{} = Stmt0) -> dot_file(_Location, Tunit, #s_dot_file{string = String}) -> Symbol = #symbol{ name = String - , section = false + , section = abs , st_value = 0 , st_size = 0 , st_info = ?ELF_ST_INFO(?STB_LOCAL, ?STT_FILE) diff --git a/erlang/apps/as/src/output.erl b/erlang/apps/as/src/output.erl index 31420a0..0cd9ba0 100644 --- a/erlang/apps/as/src/output.erl +++ b/erlang/apps/as/src/output.erl @@ -136,9 +136,12 @@ process_symbol(Symbol, Context) -> #context{tunit = Tunit, strtab = StrTab} = Context, {StName, NewStrTab} = strtab_enter(StrTab, Name), StShndx = - case tunit:get_section(Tunit, Section) of - false -> ?SHN_ABS; - #section{shndx = Shndx} -> Shndx % assigned in append_section/2 above + case Section of + false -> ?SHN_UNDEF; + abs -> ?SHN_ABS; + _ -> + #section{shndx = Shndx} = tunit:get_section(Tunit, Section), + Shndx % assigned in append_section/2 above end, NewSymbol = Symbol#symbol{st_name = StName, st_shndx = StShndx}, NewTunit = tunit:put_symbol(Tunit, NewSymbol), diff --git a/erlang/apps/as/src/tunit.hrl b/erlang/apps/as/src/tunit.hrl index cc712f7..4c2d3d6 100644 --- a/erlang/apps/as/src/tunit.hrl +++ b/erlang/apps/as/src/tunit.hrl @@ -149,7 +149,7 @@ -record(symbol, { name :: string() - , section :: false | string() % false if UNDEF or ABS + , section :: false | abs | string() %% FIXME: should contain an #elf36_Sym{} here instead , st_value :: false | non_neg_integer() , st_size :: false | non_neg_integer()