[test][objcopy] Replace GNU sed extension with BSD compatible syntax.

GNU sed offers the `,+4d` to delete the line a next four lines, but BSD
sed doesn't seem to support it (at least in macOS 10.15, but seems to do
in my 11.6 version).

Replace the usage of the extension with the equivalent syntax that works
both in BSD and GNU sed. I don't have a macOS 10.15 to check, but this
works in both my macOS 11.6 and Linux machines.

Differential Revision: https://reviews.llvm.org/D112583
This commit is contained in:
Daniel Rodríguez Troitiño
2021-10-26 17:03:08 -07:00
parent 0ef217d8e1
commit 911be05743

View File

@@ -13,24 +13,26 @@
# RUN: obj2yaml %t.copy > %t.copy.yaml
## Verify that the copy still includes the load command
# RUN: cat %t.copy.yaml | FileCheck %s --check-prefix=CHECK-COPY
# RUN: FileCheck %s --check-prefix=CHECK-COPY < %t.copy.yaml
# CHECK-COPY: - cmd: LC_CODE_SIGNATURE
# CHECK-COPY-NEXT: cmdsize: 16
# CHECK-COPY-NEXT: dataoff: 16544
# CHECK-COPY-NEXT: datasize: 304
## Remove information changed by regeneration of load command:
## - __LINKEDIT segment filesize may change
## - LC_CODE_SIGNATURE command dataoff and datasize may change
## - __LINKEDIT segment filesize may change (4 lines)
## - LC_CODE_SIGNATURE command dataoff and datasize may change (3 lines)
## - __LINKEDIT data locations may change
## NOTE: The {N;N;N;N;d} means delete the next four lines for BSD and GNU sed.
## The ,+4d is a GNU extension which seems not to work in macOS 10.15
# RUN: sed -e '/__LINKEDIT/,+4d' \
# RUN: -e '/LC_CODE_SIGNATURE/,+3d' \
# RUN: sed -e '/__LINKEDIT/{N;N;N;N;d;}' \
# RUN: -e '/LC_CODE_SIGNATURE/{N;N;N;d}' \
# RUN: -e '/n_strx/d' \
# RUN: -e '/dyld_stub_binder/d' %t.yaml > %t.clean.yaml
# RUN: sed -e '/__LINKEDIT/,+4d' \
# RUN: -e '/LC_CODE_SIGNATURE/,+3d' \
# RUN: sed -e '/__LINKEDIT/{N;N;N;N;d;}' \
# RUN: -e '/LC_CODE_SIGNATURE/{N;N;N;d;}' \
# RUN: -e '/n_strx/d' \
# RUN: -e '/dyld_stub_binder/d' %t.copy.yaml > %t.copy.clean.yaml