Sync with base:

Allow preemption of functions with protected visibility.  Disallowing this
makes no sense.  Yes it breaks function address equality and therefore
the expectations of the standard C language.  However declaring symbols
with protected visibility isn't standard C in the first place.

from Brad (maintainer)
This commit is contained in:
ajacoutot 2018-09-30 10:57:28 +00:00
parent 14407796aa
commit de82d6b432
2 changed files with 24 additions and 2 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.186 2018/09/21 08:56:06 ajacoutot Exp $
# $OpenBSD: Makefile,v 1.187 2018/09/30 10:57:28 ajacoutot Exp $
# XXX: Remember to bump MODCLANG_VERSION in lang/clang/clang.port.mk when
# updating this port.
@ -19,7 +19,7 @@ PKGNAME = llvm-${LLVM_V}
PKGSPEC-main = llvm-=${LLVM_V}
PKGNAME-main = llvm-${LLVM_V}
PKGNAME-python = py-llvm-${LLVM_V}
REVISION-main = 6
REVISION-main = 7
CATEGORIES = devel
DISTFILES = llvm-${LLVM_V}.src${EXTRACT_SUFX} \
cfe-${LLVM_V}.src${EXTRACT_SUFX} \

View File

@ -0,0 +1,22 @@
$OpenBSD: patch-tools_lld_ELF_Relocations_cpp,v 1.1 2018/09/30 10:57:28 ajacoutot Exp $
Allow preemption of functions with protected visibility. Disallowing this
makes no sense. Yes it breaks function address equality and therefore
the expectations of the standard C language. However declaring symbols
with protected visibility isn't standard C in the first place.
Fixes linking non-PIC/PIE code with lld on amd64.
Index: tools/lld/ELF/Relocations.cpp
--- tools/lld/ELF/Relocations.cpp.orig
+++ tools/lld/ELF/Relocations.cpp
@@ -630,7 +630,8 @@ static RelExpr adjustExpr(Symbol &Sym, RelExpr Expr, R
if (!Sym.isShared() || Config->Shared)
return Expr;
- if (Sym.getVisibility() != STV_DEFAULT) {
+ if (Sym.getVisibility() != STV_DEFAULT &&
+ (Sym.getVisibility() != STV_PROTECTED || !Sym.isFunc())) {
error("cannot preempt symbol: " + toString(Sym) +
getLocation(S, Sym, RelOff));
return Expr;