Skip to content

Commit ea91f90

Browse files
Steven6798quic-seaswara
authored andcommitted
[ELD] Fix inconsistent handling of unknown -z options
Make unknown `-z` sub-options follow the same handling as unknown options by emitting a warning instead of an error. Fix #1122 Signed-off-by: Steven Ramirez Rosa <ramirezr@qti.qualcomm.com>
1 parent 5fbafa2 commit ea91f90

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

lib/LinkerWrapper/GnuLdDriver.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -778,10 +778,8 @@ bool GnuLdDriver::processOptions(llvm::opt::InputArgList &Args) {
778778
ZKind = eld::ZOption::MaxPageSize;
779779
ZOpt.drop_front(14).getAsInteger(0, Zval);
780780
}
781-
if (!Config.options().addZOption(eld::ZOption(ZKind, Zval))) {
782-
errs() << "Invalid -z option specified " << ZOpt << "\n";
783-
return false;
784-
}
781+
if (!Config.options().addZOption(eld::ZOption(ZKind, Zval)))
782+
Config.raise(Diag::warn_unsupported_option) << "-z " + ZOpt.str();
785783
}
786784

787785
// --image-base

test/Common/standalone/CommandLine/ZDefs/ZDefs.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
RUN: %clang %clangopts -c %p/Inputs/1.c -o %t1.1.o
77
RUN: %link %linkopts -zdefs %t1.1.o -o %t2.out
88
RUN: %link %linkopts -z defs %t1.1.o -o %t2.out.sep
9-
RUN: %not %link %linkopts -z blah %t1.1.o -o %t2.out.err 2>&1 | %filecheck %s -check-prefix=ERROPT
9+
RUN: %link %linkopts -z blah %t1.1.o -o %t2.out.err 2>&1 | %filecheck %s -check-prefix=WARNING
1010
RUN: %readelf -s %t2.out -W | %filecheck %s
1111
RUN: %readelf -s %t2.out.sep -W | %filecheck %s
1212
#CHECK: foo
13-
#ERROPT: blah
13+
#WARNING: Warning: Unrecognized option `-z blah'
1414
#END_TEST

0 commit comments

Comments
 (0)