blob: bd86d989b150e7ee503ae645477ea9f201c41422 [file] [log] [blame]
Lorenz Brun2e30e882020-06-24 15:17:29 +02001# Copyright 2020 The Monogon Project Authors.
2#
3# SPDX-License-Identifier: Apache-2.0
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
17cc_binary(
18 name = "qboot-elf",
19 srcs = [
20 "code16.c",
21 "code32seg.c",
22 "cstart.S",
23 "entry.S",
24 "fw_cfg.c",
25 "hwsetup.c",
26 "linuxboot.c",
27 "main.c",
28 "malloc.c",
29 "mptable.c",
30 "pci.c",
31 "printf.c",
32 "string.c",
33 "smbios.c",
34 "tables.c",
35 "benchmark.h",
36 ] + glob(["include/*.h"]),
37 copts = [
38 "-m32",
39 "-march=i386",
40 "-mregparm=3",
41 "-fno-stack-protector",
42 "-fno-delete-null-pointer-checks",
43 "-ffreestanding",
44 "-mstringop-strategy=rep_byte",
45 "-minline-all-stringops",
46 "-fno-pic",
47 ],
48 includes = [
49 "include",
50 ],
51 additional_linker_inputs = [
52 "flat.lds",
53 ],
54 linkopts = [
55 "-nostdlib",
56 "-m32",
57 "-Wl,--build-id=none",
58 "-Wl,-T$(location flat.lds)",
59 "-no-pie",
60 ],
61)
62
63# TODO(q3k): move to starlark rule for hermeticity, use toolchain objcopy
64genrule(
65 name = "qboot-bin",
66 srcs = [":qboot-elf"],
67 outs = ["bios.bin"],
68 cmd = "objcopy -O binary $< $@",
69 visibility = ["//visibility:public"],
70)