Index: ELF/Relocations.cpp =================================================================== --- ELF/Relocations.cpp +++ ELF/Relocations.cpp @@ -428,10 +428,10 @@ // only memory. We can hack around it if we are producing an executable and // the refered symbol can be preemepted to refer to the executable. if (Config->Shared || (Config->Pic && !isRelExpr(Expr))) { - StringRef Name = Body.isLocal() ? getLocalSymbolName(File, Body) - : Body.getName(); - error("can't create dynamic relocation " + getRelName(Type) + - " against symbol " + Name); + error("can't create dynamic relocation " + getRelName(Type) + " against " + + (Body.isLocal() && !Body.getNameOffset() ? "readonly segment" : + "symbol " + (Body.isLocal() ? getLocalSymbolName(File, Body) + : Body.getName()))); return Expr; } if (Body.getVisibility() != STV_DEFAULT) { Index: test/ELF/dynamic-reloc-in-ro.s =================================================================== --- test/ELF/dynamic-reloc-in-ro.s +++ test/ELF/dynamic-reloc-in-ro.s @@ -5,4 +5,4 @@ foo: .quad foo -// CHECK: can't create dynamic relocation R_X86_64_64 against symbol +// CHECK: can't create dynamic relocation R_X86_64_64 against readonly segment