https://github.com/yingcong-wu updated 
https://github.com/llvm/llvm-project/pull/154902

>From 57ebc553828bf696b4bde30789e609ba96e94d6d Mon Sep 17 00:00:00 2001
From: Wu Yingcong <yingcong...@intel.com>
Date: Fri, 22 Aug 2025 15:16:47 +0800
Subject: [PATCH 1/7] fix missing by one bug

---
 libunwind/src/DwarfParser.hpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libunwind/src/DwarfParser.hpp b/libunwind/src/DwarfParser.hpp
index 7e85025dd054d..25250e0810987 100644
--- a/libunwind/src/DwarfParser.hpp
+++ b/libunwind/src/DwarfParser.hpp
@@ -273,7 +273,7 @@ bool CFI_Parser<A>::findFDE(A &addressSpace, pint_t pc, 
pint_t ehSectionStart,
           pint_t pcRange = addressSpace.getEncodedP(
               p, nextCFI, cieInfo->pointerEncoding & 0x0F);
           // Test if pc is within the function this FDE covers.
-          if ((pcStart < pc) && (pc <= pcStart + pcRange)) {
+          if ((pcStart <= pc) && (pc < pcStart + pcRange)) {
             // parse rest of info
             fdeInfo->lsda = 0;
             // check for augmentation length

>From 3b1e1f76fc66fbcc549280fd9a60eeeb6eab52ca Mon Sep 17 00:00:00 2001
From: Wu Yingcong <yingcong...@intel.com>
Date: Mon, 25 Aug 2025 09:52:18 +0800
Subject: [PATCH 2/7] empty commit

trigger ci

>From fbf9b3f03b1d2ee0bad1df58ca05be50139da378 Mon Sep 17 00:00:00 2001
From: "Wu, Yingcong" <yingcong...@intel.com>
Date: Thu, 28 Aug 2025 14:11:12 +0800
Subject: [PATCH 3/7] add test

---
 libunwind/test/eh_frame_fde_pc_range.pass.cpp | 47 +++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 libunwind/test/eh_frame_fde_pc_range.pass.cpp

diff --git a/libunwind/test/eh_frame_fde_pc_range.pass.cpp 
b/libunwind/test/eh_frame_fde_pc_range.pass.cpp
new file mode 100644
index 0000000000000..b77287cc3c243
--- /dev/null
+++ b/libunwind/test/eh_frame_fde_pc_range.pass.cpp
@@ -0,0 +1,47 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// Manually marking the .eh_frame_hdr as DW_EH_PE_omit to make libunwind to do
+// the linear search.
+
+// clang-format off
+// REQUIRES: target={{x86_64-.+-linux-gnu}}
+// RUN: %{build}
+// RUN: objcopy --dump-section .eh_frame_hdr=%t_ehf_hdr.bin %t.exe
+// RUN: echo -ne '\xFF' | dd of=%t_ehf_hdr.bin bs=1 seek=2 count=2 
conv=notrunc status=none 
+// RUN: objcopy --update-section .eh_frame_hdr=%t_ehf_hdr.bin %t.exe
+// RUN: %{exec} %t.exe
+// clang-format on
+
+#include <assert.h>
+#include <libunwind.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <unwind.h>
+
+void f() {
+  printf("123\n");
+  void *pc = __builtin_return_address(0);
+  void *fpc = (void *)&f;
+  void *fpc1 = (void *)((uintptr_t)fpc + 1);
+
+  struct dwarf_eh_bases bases;
+  const void *fde_pc = _Unwind_Find_FDE(pc, &bases);
+  const void *fde_fpc = _Unwind_Find_FDE(fpc, &bases);
+  const void *fde_fpc1 = _Unwind_Find_FDE(fpc1, &bases);
+  assert(fde_pc != NULL);
+  assert(fde_fpc != NULL);
+  assert(fde_fpc1 != NULL);
+  assert(fde_fpc == fde_fpc1);
+}
+
+int main() {
+  f();
+  return 0;
+}

>From ad2f48124deadea8f271fd58aa5286da0966d7fb Mon Sep 17 00:00:00 2001
From: "Wu, Yingcong" <yingcong...@intel.com>
Date: Thu, 28 Aug 2025 14:21:41 +0800
Subject: [PATCH 4/7] update test

---
 libunwind/test/eh_frame_fde_pc_range.pass.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libunwind/test/eh_frame_fde_pc_range.pass.cpp 
b/libunwind/test/eh_frame_fde_pc_range.pass.cpp
index b77287cc3c243..01d73bff6ffb7 100644
--- a/libunwind/test/eh_frame_fde_pc_range.pass.cpp
+++ b/libunwind/test/eh_frame_fde_pc_range.pass.cpp
@@ -9,6 +9,7 @@
 
 // Manually marking the .eh_frame_hdr as DW_EH_PE_omit to make libunwind to do
 // the linear search.
+// Assuming the begining of the function is at the start of the FDE range.
 
 // clang-format off
 // REQUIRES: target={{x86_64-.+-linux-gnu}}
@@ -35,6 +36,9 @@ void f() {
   const void *fde_pc = _Unwind_Find_FDE(pc, &bases);
   const void *fde_fpc = _Unwind_Find_FDE(fpc, &bases);
   const void *fde_fpc1 = _Unwind_Find_FDE(fpc1, &bases);
+  printf("fde_pc = %p\n", fde_pc);
+  printf("fde_fpc = %p\n", fde_fpc);
+  printf("fde_fpc1 = %p\n", fde_fpc1);
   assert(fde_pc != NULL);
   assert(fde_fpc != NULL);
   assert(fde_fpc1 != NULL);

>From 9fd7b57d16932e056c6c40c71fe90fc3f5ed25e9 Mon Sep 17 00:00:00 2001
From: "Wu, Yingcong" <yingcong...@intel.com>
Date: Thu, 28 Aug 2025 14:23:51 +0800
Subject: [PATCH 5/7] update test

---
 libunwind/test/eh_frame_fde_pc_range.pass.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libunwind/test/eh_frame_fde_pc_range.pass.cpp 
b/libunwind/test/eh_frame_fde_pc_range.pass.cpp
index 01d73bff6ffb7..46ab7f2dabe06 100644
--- a/libunwind/test/eh_frame_fde_pc_range.pass.cpp
+++ b/libunwind/test/eh_frame_fde_pc_range.pass.cpp
@@ -39,6 +39,7 @@ void f() {
   printf("fde_pc = %p\n", fde_pc);
   printf("fde_fpc = %p\n", fde_fpc);
   printf("fde_fpc1 = %p\n", fde_fpc1);
+  fflush(stdout);
   assert(fde_pc != NULL);
   assert(fde_fpc != NULL);
   assert(fde_fpc1 != NULL);

>From 1284cb7a0edda35c50adf07f74f0b5a2348e22ce Mon Sep 17 00:00:00 2001
From: "Wu, Yingcong" <yingcong...@intel.com>
Date: Thu, 28 Aug 2025 16:31:38 +0800
Subject: [PATCH 6/7] skip msan

---
 libunwind/test/eh_frame_fde_pc_range.pass.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libunwind/test/eh_frame_fde_pc_range.pass.cpp 
b/libunwind/test/eh_frame_fde_pc_range.pass.cpp
index 46ab7f2dabe06..ee1ab688359c3 100644
--- a/libunwind/test/eh_frame_fde_pc_range.pass.cpp
+++ b/libunwind/test/eh_frame_fde_pc_range.pass.cpp
@@ -13,6 +13,10 @@
 
 // clang-format off
 // REQUIRES: target={{x86_64-.+-linux-gnu}}
+
+// TODO: Figure out why this fails with Memory Sanitizer.
+// XFAIL: msan
+
 // RUN: %{build}
 // RUN: objcopy --dump-section .eh_frame_hdr=%t_ehf_hdr.bin %t.exe
 // RUN: echo -ne '\xFF' | dd of=%t_ehf_hdr.bin bs=1 seek=2 count=2 
conv=notrunc status=none 

>From 1114e5c55157a6dc45f075a640421f1cc9d914ca Mon Sep 17 00:00:00 2001
From: "Wu, Yingcong" <yingcong...@intel.com>
Date: Fri, 29 Aug 2025 10:09:41 +0800
Subject: [PATCH 7/7] test for CI

---
 libunwind/src/DwarfParser.hpp                 | 2 +-
 libunwind/test/eh_frame_fde_pc_range.pass.cpp | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/libunwind/src/DwarfParser.hpp b/libunwind/src/DwarfParser.hpp
index 25250e0810987..7e85025dd054d 100644
--- a/libunwind/src/DwarfParser.hpp
+++ b/libunwind/src/DwarfParser.hpp
@@ -273,7 +273,7 @@ bool CFI_Parser<A>::findFDE(A &addressSpace, pint_t pc, 
pint_t ehSectionStart,
           pint_t pcRange = addressSpace.getEncodedP(
               p, nextCFI, cieInfo->pointerEncoding & 0x0F);
           // Test if pc is within the function this FDE covers.
-          if ((pcStart <= pc) && (pc < pcStart + pcRange)) {
+          if ((pcStart < pc) && (pc <= pcStart + pcRange)) {
             // parse rest of info
             fdeInfo->lsda = 0;
             // check for augmentation length
diff --git a/libunwind/test/eh_frame_fde_pc_range.pass.cpp 
b/libunwind/test/eh_frame_fde_pc_range.pass.cpp
index ee1ab688359c3..3100082c0c270 100644
--- a/libunwind/test/eh_frame_fde_pc_range.pass.cpp
+++ b/libunwind/test/eh_frame_fde_pc_range.pass.cpp
@@ -14,8 +14,6 @@
 // clang-format off
 // REQUIRES: target={{x86_64-.+-linux-gnu}}
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
 
 // RUN: %{build}
 // RUN: objcopy --dump-section .eh_frame_hdr=%t_ehf_hdr.bin %t.exe

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to