Lorenz Brun | 2e30e88 | 2020-06-24 15:17:29 +0200 | [diff] [blame] | 1 | # 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 | |
| 17 | cc_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 | ], |
Lorenz Brun | 735119f | 2021-03-11 00:30:01 +0100 | [diff] [blame^] | 48 | features = ["-link_full_libc", "-cpp"], |
Lorenz Brun | 2e30e88 | 2020-06-24 15:17:29 +0200 | [diff] [blame] | 49 | includes = [ |
| 50 | "include", |
| 51 | ], |
| 52 | additional_linker_inputs = [ |
| 53 | "flat.lds", |
| 54 | ], |
| 55 | linkopts = [ |
| 56 | "-nostdlib", |
| 57 | "-m32", |
| 58 | "-Wl,--build-id=none", |
| 59 | "-Wl,-T$(location flat.lds)", |
| 60 | "-no-pie", |
| 61 | ], |
| 62 | ) |
| 63 | |
| 64 | # TODO(q3k): move to starlark rule for hermeticity, use toolchain objcopy |
| 65 | genrule( |
| 66 | name = "qboot-bin", |
| 67 | srcs = [":qboot-elf"], |
| 68 | outs = ["bios.bin"], |
| 69 | cmd = "objcopy -O binary $< $@", |
| 70 | visibility = ["//visibility:public"], |
| 71 | ) |