From 9cbb6dd1fcf59a14be4f924b9faca90bbb11dfcb Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 22 Dec 2017 21:55:28 +0000 Subject: Result of subtracting two symbols should be absolute. When two linker script symbols are subtracted, the result should be absolute. This is the behavior of binutils' ld. Patch by Erick Reyes! llvm-svn: 321390 --- lld/ELF/ScriptParser.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lld/ELF/ScriptParser.cpp') diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp index d56500ae7dd..c1176ccfa8d 100644 --- a/lld/ELF/ScriptParser.cpp +++ b/lld/ELF/ScriptParser.cpp @@ -151,6 +151,8 @@ static ExprValue add(ExprValue A, ExprValue B) { } static ExprValue sub(ExprValue A, ExprValue B) { + if (!A.isAbsolute() && !B.isAbsolute()) + return A.getValue() - B.getValue(); return {A.Sec, false, A.getSectionOffset() - B.getValue(), A.Loc}; } -- cgit v1.2.3