[Lldb-commits] [PATCH] D149397: Host: generalise `GetXcodeSDKPath`

2023-04-29 Thread Caroline Tice via Phabricator via lldb-commits
cmtice added a comment.

I'm seeing the same build failures reported by mgorny. Would you consider 
reverting this patch until you can fix it?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149397/new/

https://reviews.llvm.org/D149397

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


[Lldb-commits] [PATCH] D149397: Host: generalise `GetXcodeSDKPath`

2023-04-29 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

This change broke building with GCC:

  samu: job failed: /usr/lib/ccache/bin/x86_64-pc-linux-gnu-g++ -DHAVE_ROUND 
-D_DEBUG -D_GLIBCXX_ASSERTIONS -D_LIBCPP_ENABLE_ASSERTIONS 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/var/tmp/portage/dev-util/lldb-17.0.0_pre20230429/work/lldb_build/source/Host 
-I/var/tmp/portage/dev-util/lldb-17.0.0_pre20230429/work/lldb/source/Host 
-I/var/tmp/portage/dev-util/lldb-17.0.0_pre20230429/work/lldb/include 
-I/var/tmp/portage/dev-util/lldb-17.0.0_pre20230429/work/lldb_build/include 
-I/usr/lib/llvm/17/include -I/usr/include/python3.11 
-I/var/tmp/portage/dev-util/lldb-17.0.0_pre20230429/work/lldb/tools/clang/include
 
-I/var/tmp/portage/dev-util/lldb-17.0.0_pre20230429/work/lldb_build/../clang/include
 -I/var/tmp/portage/dev-util/lldb-17.0.0_pre20230429/work/lldb/source 
-I/var/tmp/portage/dev-util/lldb-17.0.0_pre20230429/work/lldb_build/source 
-isystem /usr/include/libxml2  -march=znver2 --param=l1-cache-size=32 
--param=l1-cache-line-size=64 -O2 -pipe -frecord-gcc-switches -fPIC 
-fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall 
-Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wno-missing-field-initializers -Wimplicit-fallthrough -Wno-class-memaccess 
-Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment 
-Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -Wno-deprecated-declarations 
-Wno-unknown-pragmas -Wno-strict-aliasing -Wno-stringop-truncation -std=c++17 
-UNDEBUG -MD -MT source/Host/CMakeFiles/lldbHost.dir/posix/PipePosix.cpp.o -MF 
source/Host/CMakeFiles/lldbHost.dir/posix/PipePosix.cpp.o.d -o 
source/Host/CMakeFiles/lldbHost.dir/posix/PipePosix.cpp.o -c 
/var/tmp/portage/dev-util/lldb-17.0.0_pre20230429/work/lldb/source/Host/posix/PipePosix.cpp
  In file included from 
/var/tmp/portage/dev-util/lldb-17.0.0_pre20230429/work/lldb/include/lldb/Host/posix/HostInfoPosix.h:12,
   from 
/var/tmp/portage/dev-util/lldb-17.0.0_pre20230429/work/lldb/include/lldb/Host/linux/HostInfoLinux.h:12,
   from 
/var/tmp/portage/dev-util/lldb-17.0.0_pre20230429/work/lldb/include/lldb/Host/HostInfo.h:43,
   from 
/var/tmp/portage/dev-util/lldb-17.0.0_pre20230429/work/lldb/source/Host/posix/PipePosix.cpp:10:
  
/var/tmp/portage/dev-util/lldb-17.0.0_pre20230429/work/lldb/include/lldb/Host/HostInfoBase.h:130:29:
 error: declaration of ‘std::optional 
lldb_private::HostInfoBase::SDKOptions::XcodeSDK’ changes meaning of ‘XcodeSDK’ 
[-Wchanges-meaning]
130 | std::optional XcodeSDK;
| ^~~~
  
/var/tmp/portage/dev-util/lldb-17.0.0_pre20230429/work/lldb/include/lldb/Host/HostInfoBase.h:130:19:
 note: used here to mean ‘class lldb_private::XcodeSDK’
130 | std::optional XcodeSDK;
|   ^~~~
  In file included from 
/var/tmp/portage/dev-util/lldb-17.0.0_pre20230429/work/lldb/include/lldb/Host/HostInfoBase.h:16:
  
/var/tmp/portage/dev-util/lldb-17.0.0_pre20230429/work/lldb/include/lldb/Utility/XcodeSDK.h:24:7:
 note: declared here
 24 | class XcodeSDK {
|   ^~~~
  samu: subcommands failed


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149397/new/

https://reviews.llvm.org/D149397

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


[Lldb-commits] [PATCH] D146058: [lldb][gnustep] Add basic test and infrastructure for GNUstep ObjC runtime

2023-04-29 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz updated this revision to Diff 518169.
sgraenitz edited the summary of this revision.
sgraenitz added a comment.

Rebase and double-check default config: GNUstep disabled, objc-gnustep-print 
test unsupported


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146058/new/

https://reviews.llvm.org/D146058

Files:
  lldb/cmake/modules/FindGNUstepObjC.cmake
  lldb/test/CMakeLists.txt
  lldb/test/Shell/Expr/objc-gnustep-print.m
  lldb/test/Shell/helper/build.py
  lldb/test/Shell/helper/toolchain.py
  lldb/test/Shell/lit.cfg.py
  lldb/test/Shell/lit.site.cfg.py.in

Index: lldb/test/Shell/lit.site.cfg.py.in
===
--- lldb/test/Shell/lit.site.cfg.py.in
+++ lldb/test/Shell/lit.site.cfg.py.in
@@ -16,6 +16,7 @@
 config.target_triple = "@LLVM_TARGET_TRIPLE@"
 config.python_executable = "@Python3_EXECUTABLE@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@
+config.objc_gnustep_dir = "@LLDB_TEST_OBJC_GNUSTEP_DIR@"
 config.lldb_enable_lzma = @LLDB_ENABLE_LZMA@
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.lldb_bitness = 64 if @LLDB_IS_64_BITS@ else 32
Index: lldb/test/Shell/lit.cfg.py
===
--- lldb/test/Shell/lit.cfg.py
+++ lldb/test/Shell/lit.cfg.py
@@ -24,7 +24,7 @@
 
 # suffixes: A list of file extensions to treat as test files. This is overriden
 # by individual lit.local.cfg files in the test subdirectories.
-config.suffixes = ['.test', '.cpp', '.s']
+config.suffixes = ['.test', '.cpp', '.s', '.m']
 
 # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
 # subdirectories contain auxiliary inputs for various tests in their parent
@@ -135,6 +135,14 @@
 if config.have_lldb_server:
 config.available_features.add('lldb-server')
 
+if config.objc_gnustep_dir:
+config.available_features.add('objc-gnustep')
+if platform.system() == 'Windows':
+# objc.dll must be in PATH since Windows has no rpath
+config.environment['PATH'] = os.path.pathsep.join((
+os.path.join(config.objc_gnustep_dir, 'lib'),
+config.environment.get('PATH','')))
+
 # NetBSD permits setting dbregs either if one is root
 # or if user_set_dbregs is enabled
 can_set_dbregs = True
Index: lldb/test/Shell/helper/toolchain.py
===
--- lldb/test/Shell/helper/toolchain.py
+++ lldb/test/Shell/helper/toolchain.py
@@ -42,6 +42,8 @@
 build_script_args.append('--tools-dir={0}'.format(config.lldb_tools_dir))
 if config.llvm_libs_dir:
 build_script_args.append('--libs-dir={0}'.format(config.llvm_libs_dir))
+if config.objc_gnustep_dir:
+build_script_args.append('--objc-gnustep-dir="{0}"'.format(config.objc_gnustep_dir))
 
 lldb_init = _get_lldb_init_path(config)
 
Index: lldb/test/Shell/helper/build.py
===
--- lldb/test/Shell/helper/build.py
+++ lldb/test/Shell/helper/build.py
@@ -49,6 +49,18 @@
 action='append',
 help='If specified, a path to search in addition to PATH when --compiler is not an exact path')
 
+parser.add_argument('--objc-gnustep-dir',
+metavar='directory',
+dest='objc_gnustep_dir',
+required=False,
+help='If specified, a path to GNUstep libobjc2 runtime for use on Windows and Linux')
+
+parser.add_argument('--objc-gnustep',
+dest='objc_gnustep',
+action='store_true',
+default=False,
+help='Include and link GNUstep libobjc2 (Windows and Linux only)')
+
 if sys.platform == 'darwin':
 parser.add_argument('--apple-sdk',
 metavar='apple_sdk',
@@ -238,6 +250,10 @@
 self.obj_ext = obj_ext
 self.lib_paths = args.libs_dir
 self.std = args.std
+assert not args.objc_gnustep or args.objc_gnustep_dir, \
+   "--objc-gnustep specified without path to libobjc2"
+self.objc_gnustep_inc = os.path.join(args.objc_gnustep_dir, 'include') if args.objc_gnustep_dir else None
+self.objc_gnustep_lib = os.path.join(args.objc_gnustep_dir, 'lib') if args.objc_gnustep_dir else None
 
 def _exe_file_name(self):
 assert self.mode != 'compile'
@@ -656,15 +672,20 @@
 args.append('-static')
 args.append('-c')
 
-args.extend(['-o', obj])
-args.append(source)
-
 if sys.platform == 'darwin':
 args.extend(['-isysroot', self.apple_sdk])
+elif self.objc_gnustep_inc:
+if source.endswith('.m') or source.endswith('.mm'):
+args.extend(['-fobjc-runtime=gnustep-2.0', '-I', self.objc_gnustep_inc])
+if sys.platform == "win32":
+args.extend(['-Xclang', '-gcodeview', '-Xclang', 

[Lldb-commits] [lldb] 64a2520 - [lldb][ObjectFileELF] Support AArch32 in ApplyRelocations

2023-04-29 Thread Stefan Gränitz via lldb-commits

Author: Stefan Gränitz
Date: 2023-04-29T17:34:39+02:00
New Revision: 64a2520bacb59dac43bb4fd19ff1788d785102de

URL: 
https://github.com/llvm/llvm-project/commit/64a2520bacb59dac43bb4fd19ff1788d785102de
DIFF: 
https://github.com/llvm/llvm-project/commit/64a2520bacb59dac43bb4fd19ff1788d785102de.diff

LOG: [lldb][ObjectFileELF] Support AArch32 in ApplyRelocations

Allow the ObjectFileELF plugin to resolve R_ARM_ABS32 relocations from AArch32 
object files. This fixes https://github.com/llvm/llvm-project/issues/61948

The existing architectures work with RELA-type relocation records that read 
addend from the relocation entry. REL-type relocations in AArch32 store addend 
in-place.
The new function doesn't re-use ELFRelocation::RelocAddend32(), because the 
interface doesn't match: in addition to the relocation entry we need the actual 
target section memory.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D147642

Added: 
lldb/test/Shell/ObjectFile/ELF/aarch32-relocations.yaml

Modified: 
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp 
b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 2443d83a3cb3a..11fee6e4e7b96 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -2637,6 +2637,44 @@ static void ApplyELF64ABS32Relocation(Symtab *symtab, 
ELFRelocation ,
   }
 }
 
+static void ApplyELF32ABS32RelRelocation(Symtab *symtab, ELFRelocation ,
+ DataExtractor _data,
+ Section *rel_section) {
+  Log *log = GetLog(LLDBLog::Modules);
+  Symbol *symbol = symtab->FindSymbolByID(ELFRelocation::RelocSymbol32(rel));
+  if (symbol) {
+addr_t value = symbol->GetAddressRef().GetFileAddress();
+if (value == LLDB_INVALID_ADDRESS) {
+  const char *name = symbol->GetName().GetCString();
+  LLDB_LOGF(log, "Debug info symbol invalid: %s", name);
+  return;
+}
+assert(llvm::isUInt<32>(value) && "Valid addresses are 32-bit");
+DataBufferSP _buffer_sp = debug_data.GetSharedDataBuffer();
+// ObjectFileELF creates a WritableDataBuffer in CreateInstance.
+WritableDataBuffer *data_buffer =
+llvm::cast(data_buffer_sp.get());
+uint8_t *dst = data_buffer->GetBytes() + rel_section->GetFileOffset() +
+   ELFRelocation::RelocOffset32(rel);
+// Implicit addend is stored inline as a signed value.
+int32_t addend;
+memcpy(, dst, sizeof(int32_t));
+// The sum must be positive. This extra check prevents UB from overflow in
+// the actual range check below.
+if (addend < 0 && static_cast(-addend) > value) {
+  LLDB_LOGF(log, "Debug info relocation overflow: 0x%" PRIx64,
+static_cast(value) + addend);
+  return;
+}
+if (!llvm::isUInt<32>(value + addend)) {
+  LLDB_LOGF(log, "Debug info relocation out of range: 0x%" PRIx64, value);
+  return;
+}
+uint32_t addr = value + addend;
+memcpy(dst, , sizeof(uint32_t));
+  }
+}
+
 unsigned ObjectFileELF::ApplyRelocations(
 Symtab *symtab, const ELFHeader *hdr, const ELFSectionHeader *rel_hdr,
 const ELFSectionHeader *symtab_hdr, const ELFSectionHeader *debug_hdr,
@@ -2667,6 +2705,21 @@ unsigned ObjectFileELF::ApplyRelocations(
 
 if (hdr->Is32Bit()) {
   switch (hdr->e_machine) {
+  case llvm::ELF::EM_ARM:
+switch (reloc_type(rel)) {
+case R_ARM_ABS32:
+  ApplyELF32ABS32RelRelocation(symtab, rel, debug_data, rel_section);
+  break;
+case R_ARM_REL32:
+  GetModule()->ReportError("unsupported AArch32 relocation:"
+   " .rel{0}[{1}], type {2}",
+   rel_section->GetName().AsCString(), i,
+   reloc_type(rel));
+  break;
+default:
+  assert(false && "unexpected relocation type");
+}
+break;
   case llvm::ELF::EM_386:
 switch (reloc_type(rel)) {
 case R_386_32:

diff  --git a/lldb/test/Shell/ObjectFile/ELF/aarch32-relocations.yaml 
b/lldb/test/Shell/ObjectFile/ELF/aarch32-relocations.yaml
new file mode 100644
index 0..1a12ba74e417e
--- /dev/null
+++ b/lldb/test/Shell/ObjectFile/ELF/aarch32-relocations.yaml
@@ -0,0 +1,62 @@
+# RUN: yaml2obj %s -o %t
+# RUN: lldb-test object-file -contents %t | FileCheck %s
+
+## Test that R_ARM_ABS32 relocations are resolved in .debug_info sections on 
aarch32.
+## REL-type relocations store implicit addend as signed values inline.
+## We relocate the symbol foo with 4 
diff erent addends and bar once in the .debug_info section.
+## Results that exceed the 32-bit range or overflow are logged and ignored.
+
+# CHECK:  Name: .debug_info
+# CHECK:

[Lldb-commits] [PATCH] D147642: [lldb][ObjectFileELF] Support AArch32 in ApplyRelocations

2023-04-29 Thread Stefan Gränitz via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG64a2520bacb5: [lldb][ObjectFileELF] Support AArch32 in 
ApplyRelocations (authored by sgraenitz).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147642/new/

https://reviews.llvm.org/D147642

Files:
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/test/Shell/ObjectFile/ELF/aarch32-relocations.yaml

Index: lldb/test/Shell/ObjectFile/ELF/aarch32-relocations.yaml
===
--- /dev/null
+++ lldb/test/Shell/ObjectFile/ELF/aarch32-relocations.yaml
@@ -0,0 +1,62 @@
+# RUN: yaml2obj %s -o %t
+# RUN: lldb-test object-file -contents %t | FileCheck %s
+
+## Test that R_ARM_ABS32 relocations are resolved in .debug_info sections on aarch32.
+## REL-type relocations store implicit addend as signed values inline.
+## We relocate the symbol foo with 4 different addends and bar once in the .debug_info section.
+## Results that exceed the 32-bit range or overflow are logged and ignored.
+
+# CHECK:  Name: .debug_info
+# CHECK:  Data:  (
+#
+#  Addends: Zero Positive Negative Overflow Out-of-range
+#    04030201 D6FF D5FF FF7F
+# CHECK-NEXT: : 2A00 2E030201  D5FF FF7F
+# CHECK-NEXT: )
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS32
+  Data:ELFDATA2LSB
+  Type:ET_REL
+  Machine: EM_ARM
+  Flags:   [ EF_ARM_EABI_VER5 ]
+Sections:
+  - Name:.text
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+  - Name:.debug_info
+Type:SHT_PROGBITS
+Content: 04030201D6FFD57F
+  - Name:.rel.debug_info
+Type:SHT_REL
+Info:.debug_info
+Relocations:
+  - Offset:  0x0
+Symbol:  foo
+Type:R_ARM_ABS32
+  - Offset:  0x4
+Symbol:  foo
+Type:R_ARM_ABS32
+  - Offset:  0x8
+Symbol:  foo
+Type:R_ARM_ABS32
+  - Offset:  0xC
+Symbol:  foo
+Type:R_ARM_ABS32
+  - Offset:  0x10
+Symbol:  bar
+Type:R_ARM_ABS32
+Symbols:
+  - Name:.debug_info
+Type:STT_SECTION
+Section: .debug_info
+  - Name:foo
+Type:STT_FUNC
+Section: .debug_info
+Value:   0x002A
+  - Name:bar
+Type:STT_FUNC
+Section: .debug_info
+Value:   0xFF00
+...
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -2637,6 +2637,44 @@
   }
 }
 
+static void ApplyELF32ABS32RelRelocation(Symtab *symtab, ELFRelocation ,
+ DataExtractor _data,
+ Section *rel_section) {
+  Log *log = GetLog(LLDBLog::Modules);
+  Symbol *symbol = symtab->FindSymbolByID(ELFRelocation::RelocSymbol32(rel));
+  if (symbol) {
+addr_t value = symbol->GetAddressRef().GetFileAddress();
+if (value == LLDB_INVALID_ADDRESS) {
+  const char *name = symbol->GetName().GetCString();
+  LLDB_LOGF(log, "Debug info symbol invalid: %s", name);
+  return;
+}
+assert(llvm::isUInt<32>(value) && "Valid addresses are 32-bit");
+DataBufferSP _buffer_sp = debug_data.GetSharedDataBuffer();
+// ObjectFileELF creates a WritableDataBuffer in CreateInstance.
+WritableDataBuffer *data_buffer =
+llvm::cast(data_buffer_sp.get());
+uint8_t *dst = data_buffer->GetBytes() + rel_section->GetFileOffset() +
+   ELFRelocation::RelocOffset32(rel);
+// Implicit addend is stored inline as a signed value.
+int32_t addend;
+memcpy(, dst, sizeof(int32_t));
+// The sum must be positive. This extra check prevents UB from overflow in
+// the actual range check below.
+if (addend < 0 && static_cast(-addend) > value) {
+  LLDB_LOGF(log, "Debug info relocation overflow: 0x%" PRIx64,
+static_cast(value) + addend);
+  return;
+}
+if (!llvm::isUInt<32>(value + addend)) {
+  LLDB_LOGF(log, "Debug info relocation out of range: 0x%" PRIx64, value);
+  return;
+}
+uint32_t addr = value + addend;
+memcpy(dst, , sizeof(uint32_t));
+  }
+}
+
 unsigned ObjectFileELF::ApplyRelocations(
 Symtab *symtab, const ELFHeader *hdr, const ELFSectionHeader *rel_hdr,
 const ELFSectionHeader *symtab_hdr, const ELFSectionHeader *debug_hdr,
@@ 

[Lldb-commits] [PATCH] D147642: [lldb][ObjectFileELF] Support AArch32 in ApplyRelocations

2023-04-29 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz updated this revision to Diff 518167.
sgraenitz marked an inline comment as done.
sgraenitz added a comment.

Address feedback and rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147642/new/

https://reviews.llvm.org/D147642

Files:
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/test/Shell/ObjectFile/ELF/aarch32-relocations.yaml

Index: lldb/test/Shell/ObjectFile/ELF/aarch32-relocations.yaml
===
--- /dev/null
+++ lldb/test/Shell/ObjectFile/ELF/aarch32-relocations.yaml
@@ -0,0 +1,62 @@
+# RUN: yaml2obj %s -o %t
+# RUN: lldb-test object-file -contents %t | FileCheck %s
+
+## Test that R_ARM_ABS32 relocations are resolved in .debug_info sections on aarch32.
+## REL-type relocations store implicit addend as signed values inline.
+## We relocate the symbol foo with 4 different addends and bar once in the .debug_info section.
+## Results that exceed the 32-bit range or overflow are logged and ignored.
+
+# CHECK:  Name: .debug_info
+# CHECK:  Data:  (
+#
+#  Addends: Zero Positive Negative Overflow Out-of-range
+#    04030201 D6FF D5FF FF7F
+# CHECK-NEXT: : 2A00 2E030201  D5FF FF7F
+# CHECK-NEXT: )
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS32
+  Data:ELFDATA2LSB
+  Type:ET_REL
+  Machine: EM_ARM
+  Flags:   [ EF_ARM_EABI_VER5 ]
+Sections:
+  - Name:.text
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+  - Name:.debug_info
+Type:SHT_PROGBITS
+Content: 04030201D6FFD57F
+  - Name:.rel.debug_info
+Type:SHT_REL
+Info:.debug_info
+Relocations:
+  - Offset:  0x0
+Symbol:  foo
+Type:R_ARM_ABS32
+  - Offset:  0x4
+Symbol:  foo
+Type:R_ARM_ABS32
+  - Offset:  0x8
+Symbol:  foo
+Type:R_ARM_ABS32
+  - Offset:  0xC
+Symbol:  foo
+Type:R_ARM_ABS32
+  - Offset:  0x10
+Symbol:  bar
+Type:R_ARM_ABS32
+Symbols:
+  - Name:.debug_info
+Type:STT_SECTION
+Section: .debug_info
+  - Name:foo
+Type:STT_FUNC
+Section: .debug_info
+Value:   0x002A
+  - Name:bar
+Type:STT_FUNC
+Section: .debug_info
+Value:   0xFF00
+...
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -2637,6 +2637,44 @@
   }
 }
 
+static void ApplyELF32ABS32RelRelocation(Symtab *symtab, ELFRelocation ,
+ DataExtractor _data,
+ Section *rel_section) {
+  Log *log = GetLog(LLDBLog::Modules);
+  Symbol *symbol = symtab->FindSymbolByID(ELFRelocation::RelocSymbol32(rel));
+  if (symbol) {
+addr_t value = symbol->GetAddressRef().GetFileAddress();
+if (value == LLDB_INVALID_ADDRESS) {
+  const char *name = symbol->GetName().GetCString();
+  LLDB_LOGF(log, "Debug info symbol invalid: %s", name);
+  return;
+}
+assert(llvm::isUInt<32>(value) && "Valid addresses are 32-bit");
+DataBufferSP _buffer_sp = debug_data.GetSharedDataBuffer();
+// ObjectFileELF creates a WritableDataBuffer in CreateInstance.
+WritableDataBuffer *data_buffer =
+llvm::cast(data_buffer_sp.get());
+uint8_t *dst = data_buffer->GetBytes() + rel_section->GetFileOffset() +
+   ELFRelocation::RelocOffset32(rel);
+// Implicit addend is stored inline as a signed value.
+int32_t addend;
+memcpy(, dst, sizeof(int32_t));
+// The sum must be positive. This extra check prevents UB from overflow in
+// the actual range check below.
+if (addend < 0 && static_cast(-addend) > value) {
+  LLDB_LOGF(log, "Debug info relocation overflow: 0x%" PRIx64,
+static_cast(value) + addend);
+  return;
+}
+if (!llvm::isUInt<32>(value + addend)) {
+  LLDB_LOGF(log, "Debug info relocation out of range: 0x%" PRIx64, value);
+  return;
+}
+uint32_t addr = value + addend;
+memcpy(dst, , sizeof(uint32_t));
+  }
+}
+
 unsigned ObjectFileELF::ApplyRelocations(
 Symtab *symtab, const ELFHeader *hdr, const ELFSectionHeader *rel_hdr,
 const ELFSectionHeader *symtab_hdr, const ELFSectionHeader *debug_hdr,
@@ -2667,6 +2705,21 @@
 
 if (hdr->Is32Bit()) {
   switch (hdr->e_machine) {
+  case 

[Lldb-commits] [PATCH] D146058: [lldb][gnustep] Add basic test and infrastructure for GNUstep ObjC runtime

2023-04-29 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz added a comment.

In D146058#4305046 , @labath wrote:

> That's not entirely what I was referring to. What I fear is the following 
> situation. A random developer makes a random patch that happens to break 
> gnustep support. That developer cannot debug that issue locally (cannot or 
> doesn't know how to build gnustep from source), so someone has to help him 
> figure out the problem. I don't want to be the person doing that. :)

Yes, that's reasonable. In my last patch, I already changed the default to 
`Off`.




Comment at: lldb/test/CMakeLists.txt:29
+# Windows and Linux have no built-in ObjC runtime. Turn this on in order to 
run tests with GNUstep.
+option(LLDB_TEST_OBJC_GNUSTEP "Enable ObjC tests with GNUstep libobjc2 on 
non-Apple platforms" Off)
+set(LLDB_TEST_OBJC_GNUSTEP_DIR "" CACHE PATH "Custom path to the GNUstep 
shared library")

See here, `Off` by default


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146058/new/

https://reviews.llvm.org/D146058

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