mirror of
https://github.com/mikpe/pdp10-tools.git
synced 2026-04-24 19:33:55 +00:00
as: handle .type <sym>,@object
This commit is contained in:
@@ -560,7 +560,12 @@ dot_size(Location, Tunit, #s_dot_size{name = Name}) ->
|
||||
fmterr(Location, "symbol ~s not defined", [Name])
|
||||
end.
|
||||
|
||||
dot_type(Location, Tunit, #s_dot_type{name = Name}) ->
|
||||
dot_type(Location, Tunit, #s_dot_type{name = Name, type = Type}) ->
|
||||
StType =
|
||||
case Type of
|
||||
function -> ?STT_FUNC;
|
||||
object -> ?STT_OBJECT
|
||||
end,
|
||||
case tunit:get_symbol(Tunit, Name) of
|
||||
false ->
|
||||
Symbol =
|
||||
@@ -568,19 +573,19 @@ dot_type(Location, Tunit, #s_dot_type{name = Name}) ->
|
||||
, section = false
|
||||
, st_value = false
|
||||
, st_size = false
|
||||
, st_info = ?ELF_ST_INFO(?STB_LOCAL, ?STT_FUNC)
|
||||
, st_info = ?ELF_ST_INFO(?STB_LOCAL, StType)
|
||||
, st_name = 0
|
||||
, st_shndx = 0
|
||||
},
|
||||
{ok, tunit:put_symbol(Tunit, Symbol)};
|
||||
#symbol{st_info = StInfo} = OldSymbol ->
|
||||
case ?ELF_ST_TYPE(StInfo) of
|
||||
?STT_FUNC -> {ok, Tunit};
|
||||
StType -> {ok, Tunit};
|
||||
?STT_NOTYPE ->
|
||||
Symbol = OldSymbol#symbol{st_info = ?ELF_ST_INFO(?ELF_ST_BIND(StInfo), ?STT_FUNC)},
|
||||
Symbol = OldSymbol#symbol{st_info = ?ELF_ST_INFO(?ELF_ST_BIND(StInfo), StType)},
|
||||
{ok, tunit:put_symbol(Tunit, Symbol)};
|
||||
Type ->
|
||||
fmterr(Location, "symbol ~s has previous incompatible type ~p", [Name, Type])
|
||||
Other ->
|
||||
fmterr(Location, "symbol ~s has previous incompatible type ~p", [Name, Other])
|
||||
end
|
||||
end.
|
||||
|
||||
|
||||
@@ -413,7 +413,7 @@ dot_text(ScanState, Location) ->
|
||||
ScanRes -> badtok("junk after .text", ScanRes)
|
||||
end.
|
||||
|
||||
%% For now only accepts ".type <sym>,@function". TODO: extend
|
||||
%% For now only accepts ".type <sym>,(@function|@object)". TODO: extend
|
||||
dot_type(ScanState, Location) ->
|
||||
case scan:token(ScanState) of
|
||||
{ok, {_Location1, {?T_SYMBOL, Name}}} ->
|
||||
@@ -423,10 +423,9 @@ dot_type(ScanState, Location) ->
|
||||
{ok, {_Location3, ?T_AT}} ->
|
||||
case scan:token(ScanState) of
|
||||
{ok, {_Location4, {?T_SYMBOL, "function"}}} ->
|
||||
case scan:token(ScanState) of
|
||||
{ok, {_Location5, ?T_NEWLINE}} -> {ok, {Location, #s_dot_type{name = Name}}};
|
||||
ScanRes -> badtok("junk after .type", ScanRes)
|
||||
end;
|
||||
dot_type(ScanState, Location, Name, function);
|
||||
{ok, {_Location4, {?T_SYMBOL, "object"}}} ->
|
||||
dot_type(ScanState, Location, Name, object);
|
||||
ScanRes -> badtok("junk after .type", ScanRes)
|
||||
end;
|
||||
ScanRes -> badtok("junk after .type", ScanRes)
|
||||
@@ -436,6 +435,12 @@ dot_type(ScanState, Location) ->
|
||||
ScanRes -> badtok("junk after .type", ScanRes)
|
||||
end.
|
||||
|
||||
dot_type(ScanState, Location, Name, Type) ->
|
||||
case scan:token(ScanState) of
|
||||
{ok, {_Location5, ?T_NEWLINE}} -> {ok, {Location, #s_dot_type{name = Name, type = Type}}};
|
||||
ScanRes -> badtok("junk after .type", ScanRes)
|
||||
end.
|
||||
|
||||
dot_word(ScanState, Location) ->
|
||||
dot_long(ScanState, Location).
|
||||
|
||||
|
||||
@@ -90,8 +90,8 @@
|
||||
%% .text [nr]
|
||||
-record(s_dot_text, {nr :: non_neg_integer()}).
|
||||
|
||||
%% .type foo,@function (TODO: extend)
|
||||
-record(s_dot_type, {name :: string()}).
|
||||
%% .type foo,(@function|@object) (TODO: extend)
|
||||
-record(s_dot_type, {name :: string(), type :: function | object}).
|
||||
|
||||
%% .2byte [expr (, expr)*]
|
||||
-record(s_dot_2byte, {exprs :: [expr()]}).
|
||||
|
||||
Reference in New Issue
Block a user