summaryrefslogtreecommitdiffhomepage
path: root/elf.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2020-03-29 18:30:04 +0200
committerRoland Reichwein <mail@reichwein.it>2020-03-29 18:30:04 +0200
commit6154309f0cd3ed5071996951465808f2503e2eb1 (patch)
treeb1666eea410e859f814ae47ca47b8b2d7d333c50 /elf.cpp
parentb0cac4997b5767526b29187fecf2a87aa1b0ebef (diff)
mcc produces first dummy executable
Diffstat (limited to 'elf.cpp')
-rw-r--r--elf.cpp7
1 files changed, 5 insertions, 2 deletions
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 <iostream>
@@ -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<uint8_t>& 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<uint8_t> Elf::Read(const std::filesystem::path& path)