[PATCH] D44207: [ELF] - Adjust rangeToString to report ranges in a different format.

Rafael Ávila de Espíndola via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 8 04:43:33 PST 2018


rafael added a comment.

LGTM

George Rimar via Phabricator via llvm-commits
<llvm-commits at lists.llvm.org> writes:

> grimar created this revision.
>  grimar added reviewers: ruiu, espindola, jhenderson.
>  Herald added subscribers: arichardson, emaste.
> 
> It was raised during the review of https://reviews.llvm.org/D43819.
>  I think LLD usually use [X, Y] for reporting ranges, like below:
>  `relocation R_386_16 out of range: 65536 is not in [0, 65535]`
> 
> Patch changes `rangeToString()` to do the same.
> 
> https://reviews.llvm.org/D44207
> 
> Files:
> 
>   ELF/Writer.cpp
>   test/ELF/linkerscript/overlapping-sections.s
> 
> Index: test/ELF/linkerscript/overlapping-sections.s
>  ===================================================================
> 
>     - test/ELF/linkerscript/overlapping-sections.s +++ test/ELF/linkerscript/overlapping-sections.s @@ -63,8 +63,8 @@
>   1. RUN: }" > %t-lma.script
>   2. RUN: not ld.lld -o %t.so --script %t-lma.script %t.o -shared 2>&1 | FileCheck %s -check-prefix LMA-OVERLAP-ERR
>   3. LMA-OVERLAP-ERR:      error: section .sec1 load address range overlaps with .sec2
>   4. LMA-OVERLAP-ERR-NEXT: >>> .sec1 range is [0x8000 -> 0x80FF]
>   5. LMA-OVERLAP-ERR-NEXT: >>> .sec2 range is [0x8080 -> 0x817F] +# LMA-OVERLAP-ERR-NEXT: >>> .sec1 range is [0x8000, 0x80FF] +# LMA-OVERLAP-ERR-NEXT: >>> .sec2 range is [0x8080, 0x817F]
>   6. Check that we create the expected binary with --noinhibit-exec or --no-check-sections:
>   7. RUN: ld.lld -o %t.so --script %t-lma.script %t.o -shared --noinhibit-exec @@ -95,8 +95,8 @@
>   8. RUN: }" > %t-vaddr.script
>   9. RUN: not ld.lld -o %t.so --script %t-vaddr.script %t.o -shared 2>&1 | FileCheck %s -check-prefix VADDR-OVERLAP-ERR
>   10. VADDR-OVERLAP-ERR:      error: section .sec1 virtual address range overlaps with .sec2
>   11. VADDR-OVERLAP-ERR-NEXT: >>> .sec1 range is [0x8000 -> 0x80FF]
>   12. VADDR-OVERLAP-ERR-NEXT: >>> .sec2 range is [0x8020 -> 0x811F] +# VADDR-OVERLAP-ERR-NEXT: >>> .sec1 range is [0x8000, 0x80FF] +# VADDR-OVERLAP-ERR-NEXT: >>> .sec2 range is [0x8020, 0x811F]
>   13. Check that the expected binary was created with --noinhibit-exec:
>   14. RUN: ld.lld -o %t.so --script %t-vaddr.script %t.o -shared --noinhibit-exec @@ -123,14 +123,14 @@
>   15. RUN: not ld.lld -o %t.so --script %t-both-overlap.script %t.o -shared 2>&1 | FileCheck %s -check-prefix BOTH-OVERLAP-ERR
>   16. BOTH-OVERLAP-ERR:      error: section .sec1 file range overlaps with .sec2
>   17. BOTH-OVERLAP-ERR-NEXT: >>> .sec1 range is [0x18000 -> 0x180FF]
>   18. BOTH-OVERLAP-ERR-NEXT: >>> .sec2 range is [0x18040 -> 0x1813F] +# BOTH-OVERLAP-ERR-NEXT: >>> .sec1 range is [0x18000, 0x180FF] +# BOTH-OVERLAP-ERR-NEXT: >>> .sec2 range is [0x18040, 0x1813F]
>   19. BOTH-OVERLAP-ERR:      error: section .sec1 virtual address range overlaps with .sec2
>   20. BOTH-OVERLAP-ERR-NEXT: >>> .sec1 range is [0x8000 -> 0x80FF]
>   21. BOTH-OVERLAP-ERR-NEXT: >>> .sec2 range is [0x8040 -> 0x813F] +# BOTH-OVERLAP-ERR-NEXT: >>> .sec1 range is [0x8000, 0x80FF] +# BOTH-OVERLAP-ERR-NEXT: >>> .sec2 range is [0x8040, 0x813F]
>   22. BOTH-OVERLAP-ERR:      error: section .sec1 load address range overlaps with .sec2
>   23. BOTH-OVERLAP-ERR-NEXT: >>> .sec1 range is [0x8000 -> 0x80FF]
>   24. BOTH-OVERLAP-ERR-NEXT: >>> .sec2 range is [0x8040 -> 0x813F] +# BOTH-OVERLAP-ERR-NEXT: >>> .sec1 range is [0x8000, 0x80FF] +# BOTH-OVERLAP-ERR-NEXT: >>> .sec2 range is [0x8040, 0x813F]
>   25. RUN: ld.lld -o %t.so --script %t-both-overlap.script %t.o -shared --noinhibit-exec
>   26. Note: I case everything overlaps we create a binary with overlapping file Index: ELF/Writer.cpp ===================================================================
>     - ELF/Writer.cpp +++ ELF/Writer.cpp @@ -1937,7 +1937,7 @@ static std::string rangeToString(uint64_t Addr, uint64_t Len) { if (Len == 0) return "<empty range at 0x" + utohexstr(Addr) + ">";
> - return "[0x" + utohexstr(Addr) + " -> 0x" + utohexstr(Addr + Len - 1) + "]"; +  return "[0x" + utohexstr(Addr) + ", 0x" + utohexstr(Addr + Len - 1) + "]"; }
> 
>   // Check whether sections overlap for a specific address range (file offsets,
> 
> Index: test/ELF/linkerscript/overlapping-sections.s
>  ===================================================================
> 
>     - test/ELF/linkerscript/overlapping-sections.s +++ test/ELF/linkerscript/overlapping-sections.s @@ -63,8 +63,8 @@
>   1. RUN: }" > %t-lma.script
>   2. RUN: not ld.lld -o %t.so --script %t-lma.script %t.o -shared 2>&1 | FileCheck %s -check-prefix LMA-OVERLAP-ERR
>   3. LMA-OVERLAP-ERR:      error: section .sec1 load address range overlaps with .sec2
>   4. LMA-OVERLAP-ERR-NEXT: >>> .sec1 range is [0x8000 -> 0x80FF]
>   5. LMA-OVERLAP-ERR-NEXT: >>> .sec2 range is [0x8080 -> 0x817F] +# LMA-OVERLAP-ERR-NEXT: >>> .sec1 range is [0x8000, 0x80FF] +# LMA-OVERLAP-ERR-NEXT: >>> .sec2 range is [0x8080, 0x817F]
>   6. Check that we create the expected binary with --noinhibit-exec or --no-check-sections:
>   7. RUN: ld.lld -o %t.so --script %t-lma.script %t.o -shared --noinhibit-exec @@ -95,8 +95,8 @@
>   8. RUN: }" > %t-vaddr.script
>   9. RUN: not ld.lld -o %t.so --script %t-vaddr.script %t.o -shared 2>&1 | FileCheck %s -check-prefix VADDR-OVERLAP-ERR
>   10. VADDR-OVERLAP-ERR:      error: section .sec1 virtual address range overlaps with .sec2
>   11. VADDR-OVERLAP-ERR-NEXT: >>> .sec1 range is [0x8000 -> 0x80FF]
>   12. VADDR-OVERLAP-ERR-NEXT: >>> .sec2 range is [0x8020 -> 0x811F] +# VADDR-OVERLAP-ERR-NEXT: >>> .sec1 range is [0x8000, 0x80FF] +# VADDR-OVERLAP-ERR-NEXT: >>> .sec2 range is [0x8020, 0x811F]
>   13. Check that the expected binary was created with --noinhibit-exec:
>   14. RUN: ld.lld -o %t.so --script %t-vaddr.script %t.o -shared --noinhibit-exec @@ -123,14 +123,14 @@
>   15. RUN: not ld.lld -o %t.so --script %t-both-overlap.script %t.o -shared 2>&1 | FileCheck %s -check-prefix BOTH-OVERLAP-ERR
>   16. BOTH-OVERLAP-ERR:      error: section .sec1 file range overlaps with .sec2
>   17. BOTH-OVERLAP-ERR-NEXT: >>> .sec1 range is [0x18000 -> 0x180FF]
>   18. BOTH-OVERLAP-ERR-NEXT: >>> .sec2 range is [0x18040 -> 0x1813F] +# BOTH-OVERLAP-ERR-NEXT: >>> .sec1 range is [0x18000, 0x180FF] +# BOTH-OVERLAP-ERR-NEXT: >>> .sec2 range is [0x18040, 0x1813F]
>   19. BOTH-OVERLAP-ERR:      error: section .sec1 virtual address range overlaps with .sec2
>   20. BOTH-OVERLAP-ERR-NEXT: >>> .sec1 range is [0x8000 -> 0x80FF]
>   21. BOTH-OVERLAP-ERR-NEXT: >>> .sec2 range is [0x8040 -> 0x813F] +# BOTH-OVERLAP-ERR-NEXT: >>> .sec1 range is [0x8000, 0x80FF] +# BOTH-OVERLAP-ERR-NEXT: >>> .sec2 range is [0x8040, 0x813F]
>   22. BOTH-OVERLAP-ERR:      error: section .sec1 load address range overlaps with .sec2
>   23. BOTH-OVERLAP-ERR-NEXT: >>> .sec1 range is [0x8000 -> 0x80FF]
>   24. BOTH-OVERLAP-ERR-NEXT: >>> .sec2 range is [0x8040 -> 0x813F] +# BOTH-OVERLAP-ERR-NEXT: >>> .sec1 range is [0x8000, 0x80FF] +# BOTH-OVERLAP-ERR-NEXT: >>> .sec2 range is [0x8040, 0x813F]
>   25. RUN: ld.lld -o %t.so --script %t-both-overlap.script %t.o -shared --noinhibit-exec
>   26. Note: I case everything overlaps we create a binary with overlapping file Index: ELF/Writer.cpp ===================================================================
>     - ELF/Writer.cpp +++ ELF/Writer.cpp @@ -1937,7 +1937,7 @@ static std::string rangeToString(uint64_t Addr, uint64_t Len) { if (Len == 0) return "<empty range at 0x" + utohexstr(Addr) + ">";
> - return "[0x" + utohexstr(Addr) + " -> 0x" + utohexstr(Addr + Len - 1) + "]"; +  return "[0x" + utohexstr(Addr) + ", 0x" + utohexstr(Addr + Len - 1) + "]"; }
> 
>   // Check whether sections overlap for a specific address range (file offsets, _______________________________________________ llvm-commits mailing list llvm-commits at lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D44207





More information about the llvm-commits mailing list