Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/Input/Input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ bool Input::resolvePathMappingFile(const LinkerConfig &PConfig) {
Input::getMemoryAreaForPath(FileName, PConfig.getDiagEngine());
if (!InputMem)
InputMem = createMemoryArea(FileName, PConfig.getDiagEngine());
if (!InputMem)
return false; // File does not exist;
setMemArea(InputMem);
// All queries to return the name of the Input return FileName for the main
// driver.
Expand Down
17 changes: 17 additions & 0 deletions test/Common/standalone/EmptyInputFile/EmptyInputFile.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#---EmptyInputFile.test----------- Executable -----------------#
#BEGIN_COMMENT
# Verify that ELD handles empty input files gracefully for:
# 1. Direct empty object file
# 2. Archive containing empty member
# 3. Thin archive containing empty member
#END_COMMENT
#START_TEST
RUN: %clang %clangopts -o %t1.o %p/Inputs/1.c -c
RUN: %touch %t1.empty.o
RUN: %ar rcs %t1.a %t1.o %t1.empty.o
RUN: %ar rcsT %t1.thin.a %t1.o %t1.empty.o
RUN: %link %emulation %linkopts %t1.empty.o 2>&1 | %filecheck %s --check-prefix=EMPTY --allow-empty
RUN: %link %emulation %linkopts %t1.a 2>&1
RUN: %link %emulation %linkopts %t1.thin.a 2>&1
#END_TEST
EMPTY: Input file {{.*}} has no contents
1 change: 1 addition & 0 deletions test/Common/standalone/EmptyInputFile/Inputs/1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int main() { return 0; }
1 change: 1 addition & 0 deletions test/Common/standalone/EmptyInputFile/Inputs/script.t
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GROUP(empty.o)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int main() { return 0; }
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[Hash]
missing.t=DOESNOTEXIST
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GROUP(/lib64/libmissing.so)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#---MissingMappingFileInput.test----------- Executable -----------------#
#BEGIN_COMMENT
# Verify that ELD handles gracefully when --mapping-file maps an input
# to a file that does not exist on disk.
# ELD should report a fatal error instead of crashing with a segfault.
#END_COMMENT
#START_TEST
RUN: %clang %clangopts -c %p/Inputs/main.c -o %t1.o
RUN: %not %link %linkopts %t1.o \
RUN: -T %p/Inputs/missing.t \
RUN: --mapping-file=%p/Inputs/mapping_missing.ini \
RUN: 2>&1 | %filecheck %s
#END_TEST
CHECK: cannot read file