From 6154309f0cd3ed5071996951465808f2503e2eb1 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sun, 29 Mar 2020 18:30:04 +0200 Subject: mcc produces first dummy executable --- elf.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'elf.cpp') diff --git a/elf.cpp b/elf.cpp index 0ad7a04..43d595d 100644 --- a/elf.cpp +++ b/elf.cpp @@ -1,6 +1,7 @@ #include "elf.h" #include "file.h" +#include "minicc.h" #include @@ -156,8 +157,8 @@ namespace { { if (elf.size() < size) { elf.resize(size); - } else - throw std::runtime_error("Padding not possible. Too many bytes already."); + } else if (elf.size() > size) + throw std::runtime_error("Padding not possible. Too many bytes already. ("s + std::to_string(elf.size()) + " > "s + std::to_string(size) + ")"s); } } @@ -195,6 +196,8 @@ void Elf::Write(const std::filesystem::path& path, const std::vector& c AddSectionHeaderSectionNames(elf, code, data); File::setFile(path, elf); + + fs::permissions(path, fs::perms::owner_exec | fs::perms::group_exec | fs::perms::others_exec, fs::perm_options::add); } std::vector Elf::Read(const std::filesystem::path& path) -- cgit v1.2.3