|
@@ -0,0 +1,58 @@
|
|
1
|
+#!/bin/bash -x
|
|
2
|
+
|
|
3
|
+# Copyright 2019 Google Inc. All Rights Reserved.
|
|
4
|
+#
|
|
5
|
+# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+# you may not use this file except in compliance with the License.
|
|
7
|
+# You may obtain a copy of the License at
|
|
8
|
+#
|
|
9
|
+# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+#
|
|
11
|
+# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+# See the License for the specific language governing permissions and
|
|
15
|
+# limitations under the License.
|
|
16
|
+
|
|
17
|
+# This is a script that generates the test executables for MacOS and Linux
|
|
18
|
+# in this directory. It should be needed very rarely to run this script.
|
|
19
|
+# It is mostly provided as a future reference on how the original binary
|
|
20
|
+# set was created.
|
|
21
|
+
|
|
22
|
+# When a new executable is generated, hardcoded addresses in the
|
|
23
|
+# functions TestObjFile, TestMachoFiles in binutils_test.go must be updated.
|
|
24
|
+
|
|
25
|
+set -o errexit
|
|
26
|
+
|
|
27
|
+cat <<EOF >/tmp/hello.c
|
|
28
|
+#include <stdio.h>
|
|
29
|
+
|
|
30
|
+int main() {
|
|
31
|
+ printf("Hello, world!\n");
|
|
32
|
+ return 0;
|
|
33
|
+}
|
|
34
|
+EOF
|
|
35
|
+
|
|
36
|
+cd $(dirname $0)
|
|
37
|
+
|
|
38
|
+if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
|
39
|
+ rm -rf exe_linux_64*
|
|
40
|
+ cc -g -o exe_linux_64 /tmp/hello.c
|
|
41
|
+elif [[ "$OSTYPE" == "darwin"* ]]; then
|
|
42
|
+ cat <<EOF >/tmp/lib.c
|
|
43
|
+ int foo() {
|
|
44
|
+ return 1;
|
|
45
|
+ }
|
|
46
|
+
|
|
47
|
+ int bar() {
|
|
48
|
+ return 2;
|
|
49
|
+ }
|
|
50
|
+ EOF
|
|
51
|
+
|
|
52
|
+ rm -rf exe_mac_64* lib_mac_64*
|
|
53
|
+ clang -g -o exe_mac_64 /tmp/hello.c
|
|
54
|
+ clang -g -o lib_mac_64 -dynamiclib /tmp/lib.ca
|
|
55
|
+else
|
|
56
|
+ echo "Unknown OS: $OSTYPE"
|
|
57
|
+ exit 1
|
|
58
|
+fi
|