[lld] r257471 - [ELF][MIPS] Do not use 'sed' to modify binary files

Simon Atanasyan via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 12 04:38:46 PST 2016


Author: atanasyan
Date: Tue Jan 12 06:38:43 2016
New Revision: 257471

URL: http://llvm.org/viewvc/llvm-project?rev=257471&view=rev
Log:
[ELF][MIPS] Do not use 'sed' to modify binary files

On Windows different versions of 'sed' work in different text/binary
mode by default. If default mode is text, sed produces corrupted binary
files. Unfortunately there is no standard command line option to select
the mode. Some 'sed' support '-b' to switch to binary mode, while other
ones support '--text' option and does not have '-b' option at all.

Added:
    lld/trunk/test/ELF/Inputs/mips-gp-disp.so
Removed:
    lld/trunk/test/ELF/Inputs/mips-gp-disp-def.s
Modified:
    lld/trunk/test/ELF/mips-gp-disp.s

Removed: lld/trunk/test/ELF/Inputs/mips-gp-disp-def.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/Inputs/mips-gp-disp-def.s?rev=257470&view=auto
==============================================================================
--- lld/trunk/test/ELF/Inputs/mips-gp-disp-def.s (original)
+++ lld/trunk/test/ELF/Inputs/mips-gp-disp-def.s (removed)
@@ -1,8 +0,0 @@
-# We cannot create a shared library with defined _gp_disp symbol
-# so we use a workaround - create a library with XXXXXXXX symbols
-# and use 'sed' to replace it by _gp_disp right in the binary file.
-  .data
-  .globl XXXXXXXX
-  .space 16
-XXXXXXXX:
-  .space 4

Added: lld/trunk/test/ELF/Inputs/mips-gp-disp.so
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/Inputs/mips-gp-disp.so?rev=257471&view=auto
==============================================================================
Binary files lld/trunk/test/ELF/Inputs/mips-gp-disp.so (added) and lld/trunk/test/ELF/Inputs/mips-gp-disp.so Tue Jan 12 06:38:43 2016 differ

Modified: lld/trunk/test/ELF/mips-gp-disp.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/mips-gp-disp.s?rev=257471&r1=257470&r2=257471&view=diff
==============================================================================
--- lld/trunk/test/ELF/mips-gp-disp.s (original)
+++ lld/trunk/test/ELF/mips-gp-disp.s Tue Jan 12 06:38:43 2016
@@ -1,14 +1,11 @@
 # Check that even if _gp_disp symbol is defined in the shared library
 # we use our own value.
 
-# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \
-# RUN:         %S/Inputs/mips-gp-disp-def.s -o %t-ext.o
-# RUN: ld.lld -shared -o %t-ext-int.so %t-ext.o
-# RUN: sed -e 's/XXXXXXXX/_gp_disp/g' %t-ext-int.so > %t-ext.so
 # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o
-# RUN: ld.lld -shared -o %t.so %t.o %t-ext.so
+# RUN: ld.lld -shared -o %t.so %t.o %S/Inputs/mips-gp-disp.so
 # RUN: llvm-readobj -symbols %t.so | FileCheck -check-prefix=INT-SO %s
-# RUN: llvm-readobj -symbols %t-ext.so | FileCheck -check-prefix=EXT-SO %s
+# RUN: llvm-readobj -symbols %S/Inputs/mips-gp-disp.so \
+# RUN:   | FileCheck -check-prefix=EXT-SO %s
 # RUN: llvm-objdump -d -t %t.so | FileCheck -check-prefix=DIS %s
 
 # REQUIRES: mips




More information about the llvm-commits mailing list