Re: [Lldb-commits] [lldb] r339068 - Add a relocation for R_AARCH64_ABS32 in ObjectFileELF

2018-08-06 Thread Davide Italiano via lldb-commits
You should be able to add a unittest for this, I think?

--
Davide
On Mon, Aug 6, 2018 at 3:04 PM Stephane Sezer via lldb-commits
 wrote:
>
> Author: sas
> Date: Mon Aug  6 15:04:08 2018
> New Revision: 339068
>
> URL: http://llvm.org/viewvc/llvm-project?rev=339068=rev
> Log:
> Add a relocation for R_AARCH64_ABS32 in ObjectFileELF
>
> Summary:
> .rela.debug_info relocations are being done via
> ObjectFileELF::ApplyRelocations for aarch64. Currently, the switch case
> that iterates over the relocation type is only implemented for a few
> different types and `assert(false)`es over the rest.
>
> Implement the relocation for R_AARCH64_ABS32 in ApplyRelocations
>
> Reviewers: sas, xiaobai, peter.smith, clayborg, javed.absar, espindola
>
> Differential Revision: https://reviews.llvm.org/D49407
>
> Change by Nathan Lanza 
>
> Modified:
> lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
>
> Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=339068=339067=339068=diff
> ==
> --- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original)
> +++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Mon Aug  6 
> 15:04:08 2018
> @@ -2697,15 +2697,20 @@ unsigned ObjectFileELF::ApplyRelocations
>  break;
>}
>case R_X86_64_32:
> -  case R_X86_64_32S: {
> +  case R_X86_64_32S:
> +  case R_AARCH64_ABS32: {
>  symbol = symtab->FindSymbolByID(reloc_symbol(rel));
>  if (symbol) {
>addr_t value = symbol->GetAddressRef().GetFileAddress();
>value += ELFRelocation::RelocAddend32(rel);
> -  assert(
> -  (reloc_type(rel) == R_X86_64_32 && (value <= UINT32_MAX)) ||
> -  (reloc_type(rel) == R_X86_64_32S &&
> -   ((int64_t)value <= INT32_MAX && (int64_t)value >= 
> INT32_MIN)));
> +  if (!((IsRelocABS32(rel) && value <= UINT32_MAX) ||
> +(reloc_type(rel) == R_X86_64_32S &&
> + ((int64_t)value <= INT32_MAX &&
> +  (int64_t)value >= INT32_MIN {
> +Log *log =
> +lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_MODULES);
> +log->Printf("Failed to apply debug info relocations");
> +  }
>uint32_t truncated_addr = (value & 0x);
>DataBufferSP _buffer_sp = debug_data.GetSharedDataBuffer();
>uint32_t *dst = reinterpret_cast(
>
>
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r339068 - Add a relocation for R_AARCH64_ABS32 in ObjectFileELF

2018-08-06 Thread Stephane Sezer via lldb-commits
Author: sas
Date: Mon Aug  6 15:04:08 2018
New Revision: 339068

URL: http://llvm.org/viewvc/llvm-project?rev=339068=rev
Log:
Add a relocation for R_AARCH64_ABS32 in ObjectFileELF

Summary:
.rela.debug_info relocations are being done via
ObjectFileELF::ApplyRelocations for aarch64. Currently, the switch case
that iterates over the relocation type is only implemented for a few
different types and `assert(false)`es over the rest.

Implement the relocation for R_AARCH64_ABS32 in ApplyRelocations

Reviewers: sas, xiaobai, peter.smith, clayborg, javed.absar, espindola

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

Change by Nathan Lanza 

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

Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=339068=339067=339068=diff
==
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Mon Aug  6 
15:04:08 2018
@@ -2697,15 +2697,20 @@ unsigned ObjectFileELF::ApplyRelocations
 break;
   }
   case R_X86_64_32:
-  case R_X86_64_32S: {
+  case R_X86_64_32S:
+  case R_AARCH64_ABS32: {
 symbol = symtab->FindSymbolByID(reloc_symbol(rel));
 if (symbol) {
   addr_t value = symbol->GetAddressRef().GetFileAddress();
   value += ELFRelocation::RelocAddend32(rel);
-  assert(
-  (reloc_type(rel) == R_X86_64_32 && (value <= UINT32_MAX)) ||
-  (reloc_type(rel) == R_X86_64_32S &&
-   ((int64_t)value <= INT32_MAX && (int64_t)value >= INT32_MIN)));
+  if (!((IsRelocABS32(rel) && value <= UINT32_MAX) ||
+(reloc_type(rel) == R_X86_64_32S &&
+ ((int64_t)value <= INT32_MAX &&
+  (int64_t)value >= INT32_MIN {
+Log *log =
+lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_MODULES);
+log->Printf("Failed to apply debug info relocations");
+  }
   uint32_t truncated_addr = (value & 0x);
   DataBufferSP _buffer_sp = debug_data.GetSharedDataBuffer();
   uint32_t *dst = reinterpret_cast(


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