fix make for a21, PIDs are always ints, linter things
This commit is contained in:
@@ -19,14 +19,16 @@ $(APPS): $(BUILDDIR)/init.o
|
||||
|
||||
# recipe for compiling imgbuilder
|
||||
$(IMGBUILDER): imgbuilder.cc $(MAKEFILE_LIST)
|
||||
@echo "CC $@"
|
||||
@if test \( ! \( -d $(@D) \) \) ;then mkdir -p $(@D);fi
|
||||
@echo "CXX $@"
|
||||
@mkdir -p $(@D)
|
||||
$(VERBOSE) $(CXX) -std=c++23 -o $@ $<
|
||||
|
||||
# recipe for building the final oostubs image
|
||||
.ONESHELL:
|
||||
# recipe for building the initrd image
|
||||
$(INITRD): $(APPS) $(IMGBUILDER)
|
||||
@echo "IMGBUILD $@"
|
||||
@if test \( ! \( -d $(@D) \) \) ;then mkdir -p $(@D);fi
|
||||
@mkdir -p $(@D)
|
||||
if [ -z "$(APPS)" ] ; then touch $@ ; exit 0 ; fi
|
||||
$(VERBOSE) $(IMGBUILDER) $(addsuffix $(BUILDDIR)/app.img, $(APPS)) > $@
|
||||
|
||||
lint::
|
||||
|
||||
@@ -41,7 +41,7 @@ $(BUILDDIR)/app: $(INITOBJ) $(ASM_OBJECTS) $(CC_OBJECTS) $(LINKER_SCRIPT) $(MAK
|
||||
$(BUILDDIR)/app.img: $(BUILDDIR)/app
|
||||
@echo "OBJCOPY $@"
|
||||
@if ! nm $< | grep "4000000 T start" >/dev/null 2>&1 ; then echo "Symbol 'start' is not first address" ; exit 1 ; fi
|
||||
@if test \( ! \( -d $(@D) \) \) ;then mkdir -p $(@D);fi
|
||||
@mkdir -p $(@D)
|
||||
$(VERBOSE) objcopy -O binary --set-section-flags .bss=alloc,load,contents $< $@
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <print>
|
||||
#include <vector>
|
||||
|
||||
constexpr size_t block_size = 4096;
|
||||
constexpr std::streamsize block_size = 4096;
|
||||
const uint8_t zeros[block_size] = {};
|
||||
|
||||
template <class... Args>
|
||||
@@ -20,7 +20,7 @@ static void die(std::format_string<Args...> fmt, Args &&...args) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static void writeBuffer(const void *data, size_t size) {
|
||||
static void writeBuffer(const void *data, std::streamsize size) {
|
||||
std::cout.write(reinterpret_cast<const char *>(data), size);
|
||||
}
|
||||
|
||||
@@ -33,35 +33,33 @@ int main(int argc, char *argv[]) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// HEADER: Number of apps + size of each app
|
||||
std::array<uint32_t, block_size / sizeof(uint32_t)> size{0};
|
||||
size[0] = static_cast<uint32_t>(argc - 1);
|
||||
|
||||
// HEADER: Number of apps + size of each app in bytes
|
||||
std::array<uint32_t, block_size / sizeof(uint32_t)> sizes{0};
|
||||
sizes[0] = static_cast<uint32_t>(argc - 1);
|
||||
for (size_t i = 1; i < argc; ++i) {
|
||||
struct stat sb;
|
||||
if (stat(argv[i], &sb) != 0) die("stat");
|
||||
// 4 GB Limit
|
||||
if (sb.st_size >= UINT32_MAX) {
|
||||
struct stat file;
|
||||
if (stat(argv[i], &file) != 0) die("stat");
|
||||
if (file.st_size >= UINT32_MAX) { // 4 GB Limit
|
||||
errno = EFBIG;
|
||||
die("stat");
|
||||
}
|
||||
size[i] = sb.st_size;
|
||||
sizes[i] = file.st_size;
|
||||
}
|
||||
writeBuffer(size.data(), block_size);
|
||||
writeBuffer(sizes.data(), block_size);
|
||||
|
||||
// DATA: Each App
|
||||
for (size_t i = 1; i < argc; ++i) {
|
||||
std::vector<char> buf(size[i]);
|
||||
std::vector<char> buf(sizes[i]);
|
||||
std::ifstream input(argv[i], std::ios::binary);
|
||||
if (!input) die("fopen");
|
||||
|
||||
input.read(buf.data(), size[i]);
|
||||
input.read(buf.data(), sizes[i]);
|
||||
|
||||
writeBuffer(buf.data(), size[i]);
|
||||
writeBuffer(buf.data(), sizes[i]);
|
||||
|
||||
// Fill to block size, if required
|
||||
if (size[i] % block_size != 0)
|
||||
writeBuffer(zeros, block_size - (size[i] % block_size));
|
||||
if (sizes[i] % block_size != 0)
|
||||
writeBuffer(zeros, block_size - (sizes[i] % block_size));
|
||||
}
|
||||
|
||||
std::cout.flush();
|
||||
|
||||
Reference in New Issue
Block a user