[llvm-branch-commits] [llvm] db07d9f - [MC] Fix llvm_unreachable when a STB_GNU_UNIQUE symbol needs a relocation
Author: Fangrui Song Date: 2022-04-05T21:43:39-07:00 New Revision: db07d9f098b3c8f180c1f3d2d21b509bc6e94113 URL: https://github.com/llvm/llvm-project/commit/db07d9f098b3c8f180c1f3d2d21b509bc6e94113 DIFF: https://github.com/llvm/llvm-project/commit/db07d9f098b3c8f180c1f3d2d21b509bc6e94113.diff LOG: [MC] Fix llvm_unreachable when a STB_GNU_UNIQUE symbol needs a relocation STB_GNU_UNIQUE should be treated in a way similar to STB_GLOBAL. This fixes an "Invalid Binding" failure in an LLVM_ENABLE_ASSERTIONS=on build for source files like glibc elf/tst-unique1mod1.c . This bug has been benign so far because (a) Clang does not produce %gnu_unique_object by itself (b) a non-assertion build likely picks the STB_GLOBAL code path anyway. (cherry picked from commit 6bdad85b26fbfd064772f2b382b27fbbf0b0afce) Added: Modified: llvm/lib/MC/ELFObjectWriter.cpp llvm/test/MC/ELF/gnu-unique.s Removed: diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp index 883735fcc293a..6fd2f7e7a7185 100644 --- a/llvm/lib/MC/ELFObjectWriter.cpp +++ b/llvm/lib/MC/ELFObjectWriter.cpp @@ -1336,6 +1336,7 @@ bool ELFObjectWriter::shouldRelocateWithSymbol(const MCAssembler &Asm, // can update it. return true; case ELF::STB_GLOBAL: + case ELF::STB_GNU_UNIQUE: // Global ELF symbols can be preempted by the dynamic linker. The relocation // has to point to the symbol for a reason analogous to the STB_WEAK case. return true; diff --git a/llvm/test/MC/ELF/gnu-unique.s b/llvm/test/MC/ELF/gnu-unique.s index 8948b33b9afbd..21609365d5277 100644 --- a/llvm/test/MC/ELF/gnu-unique.s +++ b/llvm/test/MC/ELF/gnu-unique.s @@ -1,5 +1,7 @@ # RUN: llvm-mc -triple=x86_64 %s | FileCheck %s --check-prefix=ASM -# RUN: llvm-mc -filetype=obj -triple=x86_64 %s | llvm-readelf -h -s - | FileCheck %s --check-prefix=OBJ +# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t +# RUN: llvm-readelf -h -s %t | FileCheck %s --check-prefix=OBJ +# RUN: llvm-objdump -d -r --no-show-raw-insn %t | FileCheck %s --check-prefix=DISASM # ASM: .type unique,@gnu_unique_object @@ -7,6 +9,13 @@ # OBJ: Type Bind Vis Ndx Name # OBJ: OBJECT UNIQUE DEFAULT [[#]] unique +# DISASM-LABEL: <.text>: +# DISASM-NEXT:movl $1, 0 +## unique has a non-local binding. Reference unique instead of .data +# DISASM-NEXT: R_X86_64_32S unique + + movl $1, unique + .data .globl unique .type unique, @gnu_unique_object ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 22d7bee - [PPCISelLowering] Avoid emitting calls to __multi3, __muloti4
Author: Aaron Puchert
Date: 2022-04-05T21:43:08-07:00
New Revision: 22d7bee01a5af14e16e3ecc610e8e50e072385bc
URL:
https://github.com/llvm/llvm-project/commit/22d7bee01a5af14e16e3ecc610e8e50e072385bc
DIFF:
https://github.com/llvm/llvm-project/commit/22d7bee01a5af14e16e3ecc610e8e50e072385bc.diff
LOG: [PPCISelLowering] Avoid emitting calls to __multi3, __muloti4
After D108936, @llvm.smul.with.overflow.i64 was lowered to __multi3
instead of __mulodi4, which also doesn't exist on PowerPC 32-bit, not
even with compiler-rt. Block it as well so that we get inline code.
Because libgcc doesn't have __muloti4, we block that as well.
Fixes #54460.
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D122090
Added:
Modified:
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/test/CodeGen/PowerPC/overflow-intrinsic-optimizations.ll
llvm/test/CodeGen/PowerPC/umulo-128-legalisation-lowering.ll
llvm/test/CodeGen/PowerPC/urem-seteq-illegal-types.ll
Removed:
diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index cbeae0ab03b83..6c9d43ad8c03f 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -1305,11 +1305,13 @@ PPCTargetLowering::PPCTargetLowering(const
PPCTargetMachine &TM,
setBooleanVectorContents(ZeroOrNegativeOneBooleanContent);
}
+ setLibcallName(RTLIB::MULO_I128, nullptr);
if (!isPPC64) {
// These libcalls are not available in 32-bit.
setLibcallName(RTLIB::SHL_I128, nullptr);
setLibcallName(RTLIB::SRL_I128, nullptr);
setLibcallName(RTLIB::SRA_I128, nullptr);
+setLibcallName(RTLIB::MUL_I128, nullptr);
setLibcallName(RTLIB::MULO_I64, nullptr);
}
diff --git a/llvm/test/CodeGen/PowerPC/overflow-intrinsic-optimizations.ll
b/llvm/test/CodeGen/PowerPC/overflow-intrinsic-optimizations.ll
index 83e9d8ee627e4..353dac3d2c951 100644
--- a/llvm/test/CodeGen/PowerPC/overflow-intrinsic-optimizations.ll
+++ b/llvm/test/CodeGen/PowerPC/overflow-intrinsic-optimizations.ll
@@ -1,8 +1,10 @@
; RUN: llc %s -mtriple=powerpc -o - | FileCheck %s
+; RUN: llc %s -mtriple=powerpc64 -o - | FileCheck %s
define i1 @no__mulodi4(i32 %a, i64 %b, i32* %c) {
; CHECK-LABEL: no__mulodi4
; CHECK-NOT: bl __mulodi4
+; CHECK-NOT: bl __multi3
entry:
%0 = sext i32 %a to i64
%1 = call { i64, i1 } @llvm.smul.with.overflow.i64(i64 %0, i64 %b)
@@ -16,4 +18,14 @@ entry:
ret i1 %7
}
+define i1 @no__muloti4(i128 %a, i128 %b) {
+; CHECK-LABEL: no__muloti4
+; CHECK-NOT: bl __muloti4
+entry:
+ %0 = call { i128, i1 } @llvm.smul.with.overflow.i128(i128 %a, i128 %b)
+ %1 = extractvalue { i128, i1 } %0, 1
+ ret i1 %1
+}
+
declare { i64, i1 } @llvm.smul.with.overflow.i64(i64, i64)
+declare { i128, i1 } @llvm.smul.with.overflow.i128(i128, i128)
diff --git a/llvm/test/CodeGen/PowerPC/umulo-128-legalisation-lowering.ll
b/llvm/test/CodeGen/PowerPC/umulo-128-legalisation-lowering.ll
index 335946cb24de2..778edba2719a6 100644
--- a/llvm/test/CodeGen/PowerPC/umulo-128-legalisation-lowering.ll
+++ b/llvm/test/CodeGen/PowerPC/umulo-128-legalisation-lowering.ll
@@ -32,110 +32,103 @@ define { i128, i8 } @muloti_test(i128 %l, i128 %r)
unnamed_addr #0 {
;
; PPC32-LABEL: muloti_test:
; PPC32: # %bb.0: # %start
-; PPC32-NEXT:mflr 0
-; PPC32-NEXT:stw 0, 4(1)
; PPC32-NEXT:stwu 1, -64(1)
-; PPC32-NEXT:stw 24, 32(1) # 4-byte Folded Spill
-; PPC32-NEXT:mfcr 12
; PPC32-NEXT:stw 26, 40(1) # 4-byte Folded Spill
-; PPC32-NEXT:mr 26, 7
-; PPC32-NEXT:stw 28, 48(1) # 4-byte Folded Spill
-; PPC32-NEXT:mr 28, 4
-; PPC32-NEXT:stw 29, 52(1) # 4-byte Folded Spill
-; PPC32-NEXT:mr 29, 8
-; PPC32-NEXT:mr 24, 3
-; PPC32-NEXT:li 3, 0
-; PPC32-NEXT:li 4, 0
-; PPC32-NEXT:li 7, 0
-; PPC32-NEXT:li 8, 0
+; PPC32-NEXT:mulhwu. 26, 7, 6
+; PPC32-NEXT:mcrf 1, 0
+; PPC32-NEXT:mfcr 12
+; PPC32-NEXT:cmpwi 7, 5, 0
+; PPC32-NEXT:cmpwi 2, 7, 0
+; PPC32-NEXT:stw 22, 24(1) # 4-byte Folded Spill
+; PPC32-NEXT:mulhwu. 26, 5, 8
+; PPC32-NEXT:mcrf 5, 0
; PPC32-NEXT:stw 23, 28(1) # 4-byte Folded Spill
-; PPC32-NEXT:mr 23, 5
+; PPC32-NEXT:crnor 28, 30, 10
+; PPC32-NEXT:stw 29, 52(1) # 4-byte Folded Spill
+; PPC32-NEXT:cmpwi 2, 9, 0
+; PPC32-NEXT:mulhwu. 26, 3, 10
+; PPC32-NEXT:mcrf 6, 0
+; PPC32-NEXT:cmpwi 3, 3, 0
+; PPC32-NEXT:stw 24, 32(1) # 4-byte Folded Spill
+; PPC32-NEXT:crnor 29, 10, 14
; PPC32-NEXT:stw 25, 36(1) # 4-byte Folded Spill
-; PPC32-NEXT:mr 25, 9
+; PPC32-NEXT:mulhwu. 26, 9, 4
; PPC32-NEXT:stw 27, 44(1) # 4-byte Folded Spill
-; PPC32-NEXT:mr 27, 6
+; PPC32-NEXT:crorc 28, 28, 6
+; PPC32-NEXT:stw 28, 48(1) # 4-byte Folded Spill
+; PPC32-NEXT:crorc 20, 28, 22
; PPC32-NEXT:stw 30, 56(1) # 4-byte Folded Spil
[llvm-branch-commits] [libcxx] a4681df - [libcxx] [test] Avoid spurious test breakage in clang-cl-dll configs with newer CMake
Author: Martin Storsjö
Date: 2022-04-05T21:44:05-07:00
New Revision: a4681df0202cd4967ee499c6ee640b0d09263971
URL:
https://github.com/llvm/llvm-project/commit/a4681df0202cd4967ee499c6ee640b0d09263971
DIFF:
https://github.com/llvm/llvm-project/commit/a4681df0202cd4967ee499c6ee640b0d09263971.diff
LOG: [libcxx] [test] Avoid spurious test breakage in clang-cl-dll configs with
newer CMake
The pointer.volatile.pass.cpp test was already marked as XFAIL for
mingw-dll (for reasons explained in the comment above it).
The same issue also appears in clang-cl-dll when built with newer
CMake versions. (It didn't appear with older versions of CMake, as
CMake built the library with the clang-cl flag `-std:c++latest` when
we've requested C++ 20 - which practically built it in c++2b mode with
current clang versions. With current versions of CMake, it passes
`-std:c++20` instead.)
As it succeeds/fails dependent on factors we don't
directly control, mark it as UNSUPPORTED instead of XFAIL.
Differential Revision: https://reviews.llvm.org/D122718
(cherry picked from commit b048397db8027fedf9380e7cf9213239d558fa29)
Added:
Modified:
libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.volatile.pass.cpp
Removed:
diff --git
a/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.volatile.pass.cpp
b/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.volatile.pass.cpp
index 392e50d7f3f97..0538dcd4ac142 100644
---
a/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.volatile.pass.cpp
+++
b/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.volatile.pass.cpp
@@ -10,12 +10,22 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
-// This test fails on MinGW DLL configurations, due to
+// This test fails in Windows DLL configurations, due to
// __exclude_from_explicit_instantiation__ not behaving as it should in
// combination with dllimport (https://llvm.org/PR41018), in combination
// with running tests in c++2b mode while building the library in c++20 mode.
-// (If the library was built in c++2b mode, this test would succeed.)
-// XFAIL: target={{.+}}-windows-gnu && windows-dll
+//
+// If the library was built in c++2b mode, this test would succeed.
+//
+// Older CMake passed -std:c++latest to set C++ 20 mode on clang-cl, which
+// hid this issue. With newer CMake versions, it passes -std:c++20 which
+// makes this fail.
+//
+// Marking as UNSUPPORTED instead of XFAIL to avoid spurious failures/successes
+// depending on the version of CMake used.
+// TODO: Remove this when the library is built in c++2b mode.
+//
+// UNSUPPORTED: windows-dll
// template >
// class basic_ostream;
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 5b9dd01 - [SelectionDAG][RISCV] Make RegsForValue::getCopyToRegs explicitly zero_extend constants.
Author: Craig Topper
Date: 2022-04-05T21:56:05-07:00
New Revision: 5b9dd016bec7652c311266055e5f89342cb90e60
URL:
https://github.com/llvm/llvm-project/commit/5b9dd016bec7652c311266055e5f89342cb90e60
DIFF:
https://github.com/llvm/llvm-project/commit/5b9dd016bec7652c311266055e5f89342cb90e60.diff
LOG: [SelectionDAG][RISCV] Make RegsForValue::getCopyToRegs explicitly
zero_extend constants.
ComputePHILiveOutRegInfo assumes that constant incoming values to
Phis will be zero extended if they aren't a legal type. To guarantee
that we should zero_extend rather than any_extend constants.
This fixes a bug for RISCV where any_extend of constants can be
treated as a sign_extend.
Differential Revision: https://reviews.llvm.org/D122053
(cherry picked from commit 4eb59f017903c8b70b5c5aad892bdc73516a6766)
Added:
Modified:
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/test/CodeGen/RISCV/aext-to-sext.ll
Removed:
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 01230a36e744a..c61716ba16761 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -926,7 +926,10 @@ void RegsForValue::getCopyToRegs(SDValue Val, SelectionDAG
&DAG,
CallConv.getValue(), RegVTs[Value])
: RegVTs[Value];
-if (ExtendKind == ISD::ANY_EXTEND && TLI.isZExtFree(Val, RegisterVT))
+// We need to zero extend constants that are liveout to match assumptions
+// in FunctionLoweringInfo::ComputePHILiveOutRegInfo.
+if (ExtendKind == ISD::ANY_EXTEND &&
+(TLI.isZExtFree(Val, RegisterVT) || isa(Val)))
ExtendKind = ISD::ZERO_EXTEND;
getCopyToParts(DAG, dl, Val.getValue(Val.getResNo() + Value), &Parts[Part],
diff --git a/llvm/test/CodeGen/RISCV/aext-to-sext.ll
b/llvm/test/CodeGen/RISCV/aext-to-sext.ll
index 0ffdf085109ec..b5455973c7840 100644
--- a/llvm/test/CodeGen/RISCV/aext-to-sext.ll
+++ b/llvm/test/CodeGen/RISCV/aext-to-sext.ll
@@ -80,19 +80,25 @@ bar:
; constants are zero extended for phi incoming values so an AssertZExt is
; created in 'merge' allowing the zext to be removed.
; SelectionDAG::getNode treats any_extend of i32 constants as sext for RISCV.
-; The code that creates phi incoming values in the predecessors creates an
-; any_extend for the constants which then gets treated as a sext by getNode.
-; This means the zext was not safe to remove.
+; This code used to miscompile because the code that creates phi incoming
values
+; in the predecessors created any_extend for the constants which then gets
+; treated as a sext by getNode. This made the removal of the zext incorrect.
+; SelectionDAGBuilder now creates a zero_extend instead of an any_extend to
+; match the assumption.
+; FIXME: RISCV would prefer constant inputs to phis to be sign extended.
define i64 @miscompile(i32 %c) {
; RV64I-LABEL: miscompile:
; RV64I: # %bb.0:
-; RV64I-NEXT:sext.w a1, a0
+; RV64I-NEXT:sext.w a0, a0
+; RV64I-NEXT:beqz a0, .LBB2_2
+; RV64I-NEXT: # %bb.1:
; RV64I-NEXT:li a0, -1
-; RV64I-NEXT:beqz a1, .LBB2_2
-; RV64I-NEXT: # %bb.1: # %merge
+; RV64I-NEXT:srli a0, a0, 32
; RV64I-NEXT:ret
; RV64I-NEXT: .LBB2_2: # %iffalse
-; RV64I-NEXT:li a0, -2
+; RV64I-NEXT:li a0, 1
+; RV64I-NEXT:slli a0, a0, 32
+; RV64I-NEXT:addi a0, a0, -2
; RV64I-NEXT:ret
%a = icmp ne i32 %c, 0
br i1 %a, label %iftrue, label %iffalse
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] e9b26b5 - [RISCV] Add test case for miscompile caused by treating ANY_EXTEND of constants as SIGN_EXTEND.
Author: Craig Topper
Date: 2022-04-05T21:56:05-07:00
New Revision: e9b26b5b2a709156f6d68927fa01c0a0540ea625
URL:
https://github.com/llvm/llvm-project/commit/e9b26b5b2a709156f6d68927fa01c0a0540ea625
DIFF:
https://github.com/llvm/llvm-project/commit/e9b26b5b2a709156f6d68927fa01c0a0540ea625.diff
LOG: [RISCV] Add test case for miscompile caused by treating ANY_EXTEND of
constants as SIGN_EXTEND.
The code that inserts AssertZExt based on predecessor information assumes
constants are zero extended for phi incoming values this allows
AssertZExt to be created in blocks consuming a Phi.
SelectionDAG::getNode treats any_extend of i32 constants as sext for RISCV.
The code that creates phi incoming values in the predecessors creates an
any_extend for the constants which then gets treated as a sext by getNode.
This makes the AssertZExt incorrect and can cause zexts to be
incorrectly removed.
This bug was introduced by D105918
Differential Revision: https://reviews.llvm.org/D122052
(cherry picked from commit 268371cf7b9f6fd3b9320564f1abd3615eecd2e8)
Added:
Modified:
llvm/test/CodeGen/RISCV/aext-to-sext.ll
Removed:
diff --git a/llvm/test/CodeGen/RISCV/aext-to-sext.ll
b/llvm/test/CodeGen/RISCV/aext-to-sext.ll
index df90981508a9b..0ffdf085109ec 100644
--- a/llvm/test/CodeGen/RISCV/aext-to-sext.ll
+++ b/llvm/test/CodeGen/RISCV/aext-to-sext.ll
@@ -75,3 +75,36 @@ bb:
bar:
ret i32 %b
}
+
+; The code that inserts AssertZExt based on predecessor information assumes
+; constants are zero extended for phi incoming values so an AssertZExt is
+; created in 'merge' allowing the zext to be removed.
+; SelectionDAG::getNode treats any_extend of i32 constants as sext for RISCV.
+; The code that creates phi incoming values in the predecessors creates an
+; any_extend for the constants which then gets treated as a sext by getNode.
+; This means the zext was not safe to remove.
+define i64 @miscompile(i32 %c) {
+; RV64I-LABEL: miscompile:
+; RV64I: # %bb.0:
+; RV64I-NEXT:sext.w a1, a0
+; RV64I-NEXT:li a0, -1
+; RV64I-NEXT:beqz a1, .LBB2_2
+; RV64I-NEXT: # %bb.1: # %merge
+; RV64I-NEXT:ret
+; RV64I-NEXT: .LBB2_2: # %iffalse
+; RV64I-NEXT:li a0, -2
+; RV64I-NEXT:ret
+ %a = icmp ne i32 %c, 0
+ br i1 %a, label %iftrue, label %iffalse
+
+iftrue:
+ br label %merge
+
+iffalse:
+ br label %merge
+
+merge:
+ %b = phi i32 [-1, %iftrue], [-2, %iffalse]
+ %d = zext i32 %b to i64
+ ret i64 %d
+}
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] c9ec490 - [llvm-objdump][test] dos2unix some files
Author: Fangrui Song Date: 2022-04-05T22:23:09-07:00 New Revision: c9ec4902c3e32ce329db26e3f42c5e93c3135e57 URL: https://github.com/llvm/llvm-project/commit/c9ec4902c3e32ce329db26e3f42c5e93c3135e57 DIFF: https://github.com/llvm/llvm-project/commit/c9ec4902c3e32ce329db26e3f42c5e93c3135e57.diff LOG: [llvm-objdump][test] dos2unix some files (cherry picked from commit 423af54cbef7b90199e01162dcea6d3e62539e8c) Added: Modified: llvm/test/tools/llvm-objdump/ELF/private-headers.test llvm/test/tools/llvm-objdump/ELF/program-headers.test Removed: diff --git a/llvm/test/tools/llvm-objdump/ELF/private-headers.test b/llvm/test/tools/llvm-objdump/ELF/private-headers.test index bf18f5810c571..eefdc8440385c 100644 --- a/llvm/test/tools/llvm-objdump/ELF/private-headers.test +++ b/llvm/test/tools/llvm-objdump/ELF/private-headers.test @@ -1,65 +1,65 @@ -## Check that with ELF input --private-headers outputs the program header, -## dynamic section and version definitions. -# RUN: yaml2obj %s -o %t -# RUN: llvm-objdump --private-headers %t | FileCheck %s - -# CHECK: Program Header: -# CHECK-NEXT: LOAD off0x00b0 vaddr 0x1000 paddr 0x1000 align 2**0 -# CHECK-NEXT: filesz 0x003d memsz 0x003d flags --- -# CHECK-NEXT: DYNAMIC off 0x00cd vaddr 0x101d paddr 0x101d align 2**0 -# CHECK-NEXT: filesz 0x0020 memsz 0x0020 flags --- -# CHECK: Dynamic Section: -# CHECK-NEXT: NEEDED bar -# CHECK: Version definitions: -# CHECK-NEXT: 1 0x01 0x075bcd15 foo -# CHECK-NEXT: 2 0x02 0x3ade68b1 VERSION_1 -# CHECK-NEXT: VERSION_2 - !ELF -FileHeader: - Class: ELFCLASS64 - Data:ELFDATA2LSB - Type:ET_EXEC - Machine: EM_X86_64 -Sections: - - Name:.dynstr -Type:SHT_STRTAB -Address: 0x1000 -Content: "0062617200666F6F0056455253494F4E5F320056455253494F4E5F3100" -# Content is: bar, foo, VERSION_2, VERSION_1 - - Name:.dynamic -Type:SHT_DYNAMIC -Flags: [ SHF_ALLOC ] -Entries: - - Tag: DT_NEEDED - Value: 0x1 - - Tag: DT_NULL - Value: 0x0 - - Name:.gnu.version_d -Type:SHT_GNU_verdef -Entries: - - Version: 1 -Flags: 1 -VersionNdx: 1 -Hash:123456789 -Names: - - foo - - Version: 1 -Flags: 2 -VersionNdx: 2 -Hash:987654321 -Names: - - VERSION_1 - - VERSION_2 -ProgramHeaders: - - Type: PT_LOAD -VAddr:0x1000 -FirstSec: .dynstr -LastSec: .dynamic - - Type: PT_DYNAMIC -VAddr:0x101D -FirstSec: .dynamic -LastSec: .dynamic -DynamicSymbols: - - Name:bar -Binding: STB_GLOBAL +## Check that with ELF input --private-headers outputs the program header, +## dynamic section and version definitions. +# RUN: yaml2obj %s -o %t +# RUN: llvm-objdump --private-headers %t | FileCheck %s + +# CHECK: Program Header: +# CHECK-NEXT: LOAD off0x00b0 vaddr 0x1000 paddr 0x1000 align 2**0 +# CHECK-NEXT: filesz 0x003d memsz 0x003d flags --- +# CHECK-NEXT: DYNAMIC off 0x00cd vaddr 0x101d paddr 0x101d align 2**0 +# CHECK-NEXT: filesz 0x0020 memsz 0x0020 flags --- +# CHECK: Dynamic Section: +# CHECK-NEXT: NEEDED bar +# CHECK: Version definitions: +# CHECK-NEXT: 1 0x01 0x075bcd15 foo +# CHECK-NEXT: 2 0x02 0x3ade68b1 VERSION_1 +# CHECK-NEXT: VERSION_2 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data:ELFDATA2LSB + Type:ET_EXEC + Machine: EM_X86_64 +Sections: + - Name:.dynstr +Type:SHT_STRTAB +Address: 0x1000 +Content: "0062617200666F6F0056455253494F4E5F320056455253494F4E5F3100" +# Content is: bar, foo, VERSION_2, VERSION_1 + - Name:.dynamic +Type:SHT_DYNAMIC +Flags: [ SHF_ALLOC ] +Entries: + - Tag: DT_NEEDED + Value: 0x1 + - Tag: DT_NULL + Value: 0x0 + - Name:.gnu.version_d +Type:SHT_GNU_verdef +Entries: + - Version: 1 +Flags: 1 +VersionNdx: 1 +Hash:123456789 +Names: + - foo + - Version: 1 +Flags: 2 +VersionNdx: 2 +Hash:987654321 +Names: + - VERSION_1 + - VERSION_2 +ProgramHeaders: + - Type: PT_LOAD +VAddr:0x1000 +FirstSec: .dynstr +LastSec: .dynamic + - Type: PT_DYNAMIC +VAddr:0x101D +FirstSec: .dynamic +LastSec: .dynamic +DynamicSymbols: + - Name:bar +Binding: STB_GLOBAL diff --git a/llvm/test/t
[llvm-branch-commits] [llvm] 311a622 - [Object][test] Fix invalid.test
Author: Fangrui Song Date: 2022-04-05T22:23:09-07:00 New Revision: 311a622edd31422c0969913285e54d4778477a12 URL: https://github.com/llvm/llvm-project/commit/311a622edd31422c0969913285e54d4778477a12 DIFF: https://github.com/llvm/llvm-project/commit/311a622edd31422c0969913285e54d4778477a12.diff LOG: [Object][test] Fix invalid.test (cherry picked from commit f7086401b7c03179b755768845956bc8e84ab266) Added: Modified: llvm/test/Object/invalid.test Removed: diff --git a/llvm/test/Object/invalid.test b/llvm/test/Object/invalid.test index ea95f6f5abcf9..58ec3cbeadd19 100644 --- a/llvm/test/Object/invalid.test +++ b/llvm/test/Object/invalid.test @@ -671,9 +671,10 @@ Sections: ## Check the case when the e_phoff field is invalid. # RUN: yaml2obj --docnum=31 %s -o %t31 -# RUN: not llvm-objdump --private-headers %t31 2>&1 | FileCheck -DFILE=%t31 %s --check-prefix=INVALID-PHOFF +# RUN: llvm-objdump --private-headers %t31 2>&1 | FileCheck -DFILE=%t31 %s --check-prefix=INVALID-PHOFF -# INVALID-PHOFF: error: '[[FILE]]': program headers are longer than binary of size 280: e_phoff = 0xff, e_phnum = 0, e_phentsize = 0 +# INVALID-PHOFF: warning: '[[FILE]]': program headers are longer than binary of size 280: e_phoff = 0xff, e_phnum = 0, e_phentsize = 0 +# INVALID-PHOFF-EMPTY: --- !ELF FileHeader: ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 1007cb7 - [llvm-objdump] --private-headers: change errors to warnings for dynamic section dumping
Author: Fangrui Song
Date: 2022-04-05T22:23:09-07:00
New Revision: 1007cb795a3c82eab231b58569ea06a2b613636a
URL:
https://github.com/llvm/llvm-project/commit/1007cb795a3c82eab231b58569ea06a2b613636a
DIFF:
https://github.com/llvm/llvm-project/commit/1007cb795a3c82eab231b58569ea06a2b613636a.diff
LOG: [llvm-objdump] --private-headers: change errors to warnings for dynamic
section dumping
Fix #54456: `objcopy --only-keep-debug` produces a linked image with invalid
empty dynamic section. llvm-objdump -p currently reports an error which seems
excessive.
```
% llvm-readelf -l a.out
llvm-readelf: warning: 'a.out': no valid dynamic table was found
...
```
Follow the spirit of llvm-readelf -l (D64472) and report a warning instead.
This allows later files to be dumped despite warnings for an input file, and
improves objdump compatibility in that the exit code is now 0 instead of 1.
```
% llvm-objdump -p a.out # new behavior
...
Program Header:
llvm-objdump: warning: 'a.out': invalid empty dynamic section
% objdump -p a.out
...
Dynamic Section:
```
Reviewed By: jhenderson, raj.khem
Differential Revision: https://reviews.llvm.org/D122505
(cherry picked from commit 11a8fc685692f56b011f851d974f0cac534f2cb8)
Added:
llvm/test/tools/llvm-objdump/ELF/dynamic-malformed.test
Modified:
llvm/lib/Object/ELF.cpp
llvm/test/tools/llvm-objdump/ELF/invalid-phdr.test
llvm/test/tools/llvm-objdump/ELF/program-headers.test
llvm/tools/llvm-objdump/ELFDump.cpp
Removed:
diff --git a/llvm/lib/Object/ELF.cpp b/llvm/lib/Object/ELF.cpp
index 6e56da1a31f3e..56a4262117551 100644
--- a/llvm/lib/Object/ELF.cpp
+++ b/llvm/lib/Object/ELF.cpp
@@ -561,11 +561,9 @@ Expected
ELFFile::dynamicEntries() const {
}
if (Dyn.empty())
-// TODO: this error is untested.
return createError("invalid empty dynamic section");
if (Dyn.back().d_tag != ELF::DT_NULL)
-// TODO: this error is untested.
return createError("dynamic sections must be DT_NULL terminated");
return Dyn;
diff --git a/llvm/test/tools/llvm-objdump/ELF/dynamic-malformed.test
b/llvm/test/tools/llvm-objdump/ELF/dynamic-malformed.test
new file mode 100644
index 0..b10e4f5e44f18
--- /dev/null
+++ b/llvm/test/tools/llvm-objdump/ELF/dynamic-malformed.test
@@ -0,0 +1,38 @@
+## An empty dynamic section is invalid. Test we report a warning instead of an
+## error, so that dumping can continue with other objects.
+# RUN: yaml2obj %s --docnum=1 -o %t.empty
+# RUN: llvm-objdump -p %t.empty 2>&1 | FileCheck %s -DFILE=%t.empty
--check-prefix=EMPTY
+
+# EMPTY: Program Header:
+# EMPTY-NEXT: warning: '[[FILE]]': invalid empty dynamic section
+# EMPTY-EMPTY:
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data:ELFDATA2LSB
+ Type:ET_EXEC
+ Machine: EM_X86_64
+Sections:
+ - Name: .dynamic
+Type: SHT_DYNAMIC
+
+# RUN: yaml2obj %s --docnum=2 -o %t.nonull
+# RUN: llvm-objdump -p %t.nonull 2>&1 | FileCheck %s -DFILE=%t.nonull
--check-prefix=NONULL
+
+# NONULL: Program Header:
+# NONULL-NEXT: warning: '[[FILE]]': dynamic sections must be DT_NULL
terminated
+# NONULL-EMPTY:
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data:ELFDATA2LSB
+ Type:ET_EXEC
+ Machine: EM_X86_64
+Sections:
+ - Name: .dynamic
+Type: SHT_DYNAMIC
+Entries:
+ - Tag: DT_SONAME
+Value: 1
diff --git a/llvm/test/tools/llvm-objdump/ELF/invalid-phdr.test
b/llvm/test/tools/llvm-objdump/ELF/invalid-phdr.test
index 94de7eacc3eca..188c8eeeff491 100644
--- a/llvm/test/tools/llvm-objdump/ELF/invalid-phdr.test
+++ b/llvm/test/tools/llvm-objdump/ELF/invalid-phdr.test
@@ -1,11 +1,12 @@
## Test how we handle the case when the e_phoff field is invalid.
# RUN: yaml2obj %s -o %t
-# RUN: not llvm-objdump --private-headers %t 2>&1 | \
+# RUN: llvm-objdump --private-headers %t 2>&1 | \
# RUN: FileCheck -DFILE=%t %s --check-prefix=INVALID-PHOFF
# INVALID-PHOFF: Program Header:
# INVALID-PHOFF-NEXT: warning: '[[FILE]]': unable to read program headers:
program headers are longer than binary of size 280: e_phoff = 0xff, e_phnum
= 0, e_phentsize = 0
-# INVALID-PHOFF-NEXT: error: '[[FILE]]': program headers are longer than
binary of size 280: e_phoff = 0xff, e_phnum = 0, e_phentsize = 0
+# INVALID-PHOFF-NEXT: warning: '[[FILE]]': program headers are longer than
binary of size 280: e_phoff = 0xff, e_phnum = 0, e_phentsize = 0
+# INVALID-PHOFF-EMPTY:
--- !ELF
FileHeader:
diff --git a/llvm/test/tools/llvm-objdump/ELF/program-headers.test
b/llvm/test/tools/llvm-objdump/ELF/program-headers.test
index 1e11334d7172f..abd4894c45124 100644
--- a/llvm/test/tools/llvm-objdump/ELF/program-headers.test
+++ b/llvm/test/tools/llvm-objdump/ELF/program-headers.test
@@ -278,12 +278,13 @@ ProgramHeaders:
## Check we report an error / warning when we are unable to read program
headers.
## Case A: the e_phentsi
[llvm-branch-commits] [lld] 3530682 - [ELF] Fix llvm_unreachable failure when COMMON is placed in SHT_PROGBITS output section
Author: Fangrui Song
Date: 2022-04-05T22:38:20-07:00
New Revision: 353068233f21bd8b904da854072e85114c566562
URL:
https://github.com/llvm/llvm-project/commit/353068233f21bd8b904da854072e85114c566562
DIFF:
https://github.com/llvm/llvm-project/commit/353068233f21bd8b904da854072e85114c566562.diff
LOG: [ELF] Fix llvm_unreachable failure when COMMON is placed in SHT_PROGBITS
output section
Fix a regression in aa27bab5a1a17e9c4168a741a6298ecaa92c1ecb: COMMON in an
SHT_PROGBITS output section caused llvm_unreachable failure.
(cherry picked from commit 1db59dc8e28819b1960dae8e7fe6d79ad4b03340)
Added:
Modified:
lld/ELF/SyntheticSections.h
lld/test/ELF/linkerscript/common.s
Removed:
diff --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h
index e609b3d7982a5..3161785988f64 100644
--- a/lld/ELF/SyntheticSections.h
+++ b/lld/ELF/SyntheticSections.h
@@ -187,9 +187,7 @@ class BuildIdSection : public SyntheticSection {
class BssSection final : public SyntheticSection {
public:
BssSection(StringRef name, uint64_t size, uint32_t alignment);
- void writeTo(uint8_t *) override {
-llvm_unreachable("unexpected writeTo() call for SHT_NOBITS section");
- }
+ void writeTo(uint8_t *) override {}
bool isNeeded() const override { return size != 0; }
size_t getSize() const override { return size; }
diff --git a/lld/test/ELF/linkerscript/common.s
b/lld/test/ELF/linkerscript/common.s
index 04b667f659128..69376011656f3 100644
--- a/lld/test/ELF/linkerscript/common.s
+++ b/lld/test/ELF/linkerscript/common.s
@@ -1,47 +1,44 @@
# REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
-# RUN: echo "SECTIONS { . = SIZEOF_HEADERS; .common : { *(COMMON) } }" >
%t.script
-# RUN: ld.lld -o %t1 --script %t.script %t
-# RUN: llvm-readobj -S --symbols %t1 | FileCheck %s
-
-# CHECK: Section {
-# CHECK: Index:
-# CHECK: Name: .common
-# CHECK-NEXT:Type: SHT_NOBITS
-# CHECK-NEXT:Flags [
-# CHECK-NEXT: SHF_ALLOC
-# CHECK-NEXT: SHF_WRITE
-# CHECK-NEXT:]
-# CHECK-NEXT:Address: 0x200
-# CHECK-NEXT:Offset: 0x
-# CHECK-NEXT:Size: 384
-# CHECK-NEXT:Link: 0
-# CHECK-NEXT:Info: 0
-# CHECK-NEXT:AddressAlignment: 256
-# CHECK-NEXT:EntrySize: 0
-# CHECK-NEXT: }
-# CHECK: Symbol {
-# CHECK: Name: q1
-# CHECK-NEXT:Value: 0x200
-# CHECK-NEXT:Size: 128
-# CHECK-NEXT:Binding: Global
-# CHECK-NEXT:Type: Object
-# CHECK-NEXT:Other: 0
-# CHECK-NEXT:Section: .common
-# CHECK-NEXT: }
-# CHECK-NEXT: Symbol {
-# CHECK-NEXT:Name: q2
-# CHECK-NEXT:Value: 0x300
-# CHECK-NEXT:Size: 128
-# CHECK-NEXT:Binding: Global
-# CHECK-NEXT:Type: Object
-# CHECK-NEXT:Other: 0
-# CHECK-NEXT:Section: .common
-# CHECK-NEXT: }
+## Test that COMMON matches common symbols.
+# RUN: rm -rf %t && split-file %s %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %t/a.s -o %t/a.o
+# RUN: ld.lld -T %t/1.t %t/a.o -o %t/a1
+# RUN: llvm-readelf -S -s %t/a1 | FileCheck %s --check-prefix=CHECK1
+# RUN: ld.lld -T %t/2.t %t/a.o -o %t/a2
+# RUN: llvm-readelf -S -s %t/a2 | FileCheck %s --check-prefix=CHECK2
+
+# CHECK1: [Nr] NameType Address Off Size ES Flg Lk Inf Al
+# CHECK1-NEXT: [ 0] NULL [[#%x,]] [[#%x,]] 00 00 0 0 0
+# CHECK1-NEXT: [ 1] .text PROGBITS [[#%x,]] [[#%x,]] 05 00 AX 0 0 4
+# CHECK1-NEXT: [ 2] .data PROGBITS [[#%x,]] [[#%x,]] 01 00 WA 0 0 1
+# CHECK1-NEXT: [ 3] .common NOBITS [[#%x,]] [[#%x,]] 000180 00 WA 0 0 256
+# CHECK1: Value Size TypeBind Vis Ndx Name
+# CHECK1-DAG: [[#%x,]] 128 OBJECT GLOBAL DEFAULT [[#]] q1
+# CHECK1-DAG: [[#%x,]] 128 OBJECT GLOBAL DEFAULT [[#]] q2
+
+# CHECK2: [Nr] NameType Address Off Size ES Flg Lk Inf Al
+# CHECK2-NEXT: [ 0] NULL [[#%x,]] [[#%x,]] 00 00 0 0 0
+# CHECK2-NEXT: [ 1] .text PROGBITS [[#%x,]] [[#%x,]] 05 00 AX 0 0 4
+# CHECK2-NEXT: [ 2] .data PROGBITS [[#%x,]] [[#%x,]] 000180 00 WA 0 0 256
+# CHECK2: Value Size TypeBind Vis Ndx Name
+# CHECK2-DAG: [[#%x,]] 128 OBJECT GLOBAL DEFAULT [[#]] q1
+# CHECK2-DAG: [[#%x,]] 128 OBJECT GLOBAL DEFAULT [[#]] q2
+
+#--- a.s
.globl _start
_start:
jmp _start
+.section .data,"aw",@progbits
+.byte 0
+
.comm q1,128,8
.comm q2,128,256
+
+#--- 1.t
+SECTIONS { . = SIZEOF_HEADERS; .common : { *(COMMON) } }
+
+#--- 2.t
+## COMMON can be placed in a SHT_PROGBITS section.
+SECTIONS { . = SIZEOF_HEADERS; .data : { *(.data) *(COMMON) } }
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
