Index: include/clang/Driver/Options.td =================================================================== --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1780,6 +1780,10 @@ Flags<[CC1Option]>, HelpText<"Place debug types in their own section (ELF Only)">; def fno_debug_types_section: Flag<["-"], "fno-debug-types-section">, Group, Flags<[CC1Option]>; +def fdwarf_base_address: Flag <["-"], "fdwarf-base-address">, Group, + Flags<[CC1Option]>, HelpText<"Use DWARF base address selection entries in debug_ranges">; +def fno_dwarf_base_address: Flag <["-"], "fno-dwarf_base_address">, Group, + Flags<[CC1Option]>; def fsplit_dwarf_inlining: Flag <["-"], "fsplit-dwarf-inlining">, Group, Flags<[CC1Option]>, HelpText<"Provide minimal debug info in the object/executable to facilitate online symbolication/stack traces in the absence of .dwo/.dwp files when using Split DWARF">; def fno_split_dwarf_inlining: Flag<["-"], "fno-split-dwarf-inlining">, Group, Index: include/clang/Frontend/CodeGenOptions.def =================================================================== --- include/clang/Frontend/CodeGenOptions.def +++ include/clang/Frontend/CodeGenOptions.def @@ -331,6 +331,9 @@ /// Whether to emit .debug_gnu_pubnames section instead of .debug_pubnames. CODEGENOPT(DebugNameTable, 2, 0) +/// Whether to use DWARF base address specifiers in .debug_ranges. +CODEGENOPT(DebugBaseAddress, 1, 0) + CODEGENOPT(NoPLT, 1, 0) /// Whether to embed source in DWARF debug line section. Index: lib/Driver/ToolChains/Clang.cpp =================================================================== --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -3188,6 +3188,11 @@ ? "-gpubnames" : "-ggnu-pubnames"); + if (Args.hasFlag(options::OPT_fdwarf_base_address, + options::OPT_fno_dwarf_base_address, false)) { + CmdArgs.push_back("-fdwarf-base-address"); + } + // -gdwarf-aranges turns on the emission of the aranges section in the // backend. // Always enabled for SCE tuning. Index: lib/Frontend/CompilerInvocation.cpp =================================================================== --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -651,6 +651,7 @@ : Args.hasArg(OPT_gpubnames) ? llvm::DICompileUnit::DebugNameTableKind::Default : llvm::DICompileUnit::DebugNameTableKind::None); + Opts.DebugBaseAddress = Args.hasArg(OPT_fdwarf_base_address); setPGOInstrumentor(Opts, Args, Diags); Opts.InstrProfileOutput =