diff options
Diffstat (limited to 'gold/script.cc')
-rw-r--r-- | gold/script.cc | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/gold/script.cc b/gold/script.cc index f5584d9..44de551 100644 --- a/gold/script.cc +++ b/gold/script.cc @@ -1141,7 +1141,20 @@ extern "C" void script_add_file(void* closurev, const char* name) { Parser_closure* closure = static_cast<Parser_closure*>(closurev); - Input_file_argument file(name, false, closure->position_dependent_options()); + std::string absname; + if (name[0] == '/') + { + absname = name; + } + else + { + // Prepend `dirname closure->filename()` to make the path absolute. + char *slash = strrchr(closure->filename(), '/'); + absname.assign(closure->filename(), + slash ? slash - closure->filename() + 1 : 0); + absname += name; + } + Input_file_argument file(absname.c_str(), false, closure->position_dependent_options()); closure->inputs()->add_file(file); } |