Index: lib/Driver/ToolChains/BareMetal.h =================================================================== --- lib/Driver/ToolChains/BareMetal.h +++ lib/Driver/ToolChains/BareMetal.h @@ -32,6 +32,7 @@ public: bool useIntegratedAs() const override { return true; } + bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override; bool isCrossCompiling() const override { return true; } bool isPICDefault() const override { return false; } bool isPIEDefault() const override { return false; } Index: lib/Driver/ToolChains/BareMetal.cpp =================================================================== --- lib/Driver/ToolChains/BareMetal.cpp +++ lib/Driver/ToolChains/BareMetal.cpp @@ -57,6 +57,14 @@ return true; } +bool BareMetal::IsUnwindTablesDefault(const ArgList &Args) const { + // Unwind tables are not emitted in C or if -fno-exceptions is supplied. + // For C++ we cannot rely on UWTable because we still need the .exidx section + // even if the function does not throw. + return Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions, + getDriver().CCCIsCXX()); +} + bool BareMetal::handlesTarget(const llvm::Triple &Triple) { return isARMBareMetal(Triple); }