From e24b529f05ebedad89823b4ca54c15dd94375f7f Mon Sep 17 00:00:00 2001 From: Mikael Pettersson Date: Sun, 24 May 2020 16:47:56 +0200 Subject: [PATCH] ld: ld_input: error if there are no input files --- erlang/apps/ld/src/ld_input.erl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/erlang/apps/ld/src/ld_input.erl b/erlang/apps/ld/src/ld_input.erl index e47c796..70a2dcd 100644 --- a/erlang/apps/ld/src/ld_input.erl +++ b/erlang/apps/ld/src/ld_input.erl @@ -30,12 +30,14 @@ -define(badelf, badelf). -define(badfile, badfile). -define(muldef_symbol, muldef_symbol). +-define(noinputfiles, noinputfiles). -define(undefined_symbols, undefined_symbols). %% Input Processing ============================================================ -spec input([{file, string()}], [string()]) -> {ok, [#input{}]} | {error, {module(), term()}}. +input(_Files = [], _UndefSyms) -> {error, {?MODULE, ?noinputfiles}}; input(Files, UndefSyms) -> UndefMap = lists:foldl(fun(UndefSym, UndefMap0) -> @@ -136,6 +138,8 @@ format_error(Reason) -> io:format("~s: ~s", [File, error:format(Reason)]); {?muldef_symbol, Symbol, File0, File} -> io:format("~s: ~s already defined in ~s", [File, Symbol, File0]); + ?noinputfiles -> + "no input files"; {?undefined_symbols, Symbols} -> ["undefined symbols:" | ["\n" ++ Symbol || Symbol <- Symbols]]