diff --git a/lld/test/wasm/build-id.test b/lld/test/wasm/build-id.test new file mode 100644 --- /dev/null +++ b/lld/test/wasm/build-id.test @@ -0,0 +1,68 @@ +# RUN: llvm-mc -filetype=obj -triple=wasm32 %p/Inputs/start.s -o %t + +# RUN: wasm-ld --build-id %t -o %t2 +# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=DEFAULT %s +# RUN: wasm-ld --build-id=fast %t -o %t2 +# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=DEFAULT %s +# RUN: wasm-ld --build-id %t -o %t2 --threads=1 +# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=DEFAULT %s + +# RUN: wasm-ld --build-id=md5 %t -o %t2 +# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=MD5 %s +# RUN: wasm-ld --build-id=md5 %t -o %t2 --threads=1 +# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=MD5 %s + +# RUN: wasm-ld --build-id=sha1 %t -o %t2 +# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=SHA1 %s +# RUN: wasm-ld --build-id=sha1 %t -o %t2 --threads=1 +# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=SHA1 %s + +# RUN: wasm-ld --build-id=tree %t -o %t2 +# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=SHA1 %s +# RUN: wasm-ld --build-id=tree %t -o %t2 --threads=1 +# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=SHA1 %s + +# RUN: wasm-ld --build-id=uuid %t -o %t2 +# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=UUID %s + +# RUN: wasm-ld --build-id=0x12345678 %t -o %t2 +# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=HEX %s + +# RUN: wasm-ld %t -o %t2 +# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=NONE %s + +# RUN: wasm-ld --build-id=md5 --build-id=none %t -o %t2 +# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=NONE %s +# RUN: wasm-ld --build-id --build-id=none %t -o %t2 +# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=NONE %s +# RUN: wasm-ld --build-id=none --build-id %t -o %t2 +# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=DEFAULT %s + +.section .data.foo,"",@ + .globl foo + .hidden foo + .p2align 2 +foo: + .int32 1 + .size foo, 4 + + +# DEFAULT: Contents of section build_id: +# DEFAULT-NEXT: 0000 08975048 c82e0d2b 9c ..PH...+. + +# MD5: Contents of section build_id: +# MD5-NEXT: 0000 10022957 9fe91546 10867be9 cef19657 ..)W...F..{....W +# MD5-NEXT: 0010 d8 . + +# SHA1: Contents of section build_id: +# SHA1-NEXT: 0000 14ad22e8 54d72438 94af85de 3c5592bd ..".T.$8.... searchPaths; llvm::CachePruningPolicy thinLTOCachePolicy; llvm::Optional> features; + std::vector buildIdVector; // The following config options do not directly correspond to any // particular command line options. diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp --- a/lld/wasm/Driver.cpp +++ b/lld/wasm/Driver.cpp @@ -348,6 +348,35 @@ return errorOrWarn; } +// Parse --build-id or --build-id=