fix(relinker): reject relocatable ELF conversion inputs
This commit is contained in:
parent
0f2683cb7d
commit
6f0f7c7461
|
|
@ -16,6 +16,12 @@ namespace Relinker {
|
|||
|
||||
using namespace Elfpatcher;
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr std::uint16_t kEtRel = 1;
|
||||
|
||||
}
|
||||
|
||||
RelinkerPipeline::RelinkerPipeline(std::shared_ptr<IElfReader> elfReader, std::shared_ptr<ISyscallScanner> syscallScanner, std::shared_ptr<ICallSiteResolver> callSiteResolver, std::shared_ptr<IValidationPolicy> validationPolicy, std::shared_ptr<ISysVDynamicSectionBuilder> dynamicSectionBuilder, std::shared_ptr<IUnusedNidFilter> unusedNidFilter, std::uint32_t unusedFilterLevel, Domain::IProgress& progress)
|
||||
: elfReader(std::move(elfReader))
|
||||
, syscallScanner(std::move(syscallScanner))
|
||||
|
|
@ -45,6 +51,9 @@ std::string RelinkerPipeline::relocationTypeName(std::uint32_t type) {
|
|||
}
|
||||
|
||||
RelinkResult RelinkerPipeline::Relink(const std::vector<std::uint8_t>& sourceElf) {
|
||||
if (elfReader->ReadHeader().Type == kEtRel)
|
||||
throw RelinkerException("ET_REL relocatable inputs are not supported");
|
||||
|
||||
auto programHeaders = elfReader->ReadProgramHeaders();
|
||||
|
||||
std::vector<std::uint8_t> textSection;
|
||||
|
|
|
|||
|
|
@ -95,6 +95,16 @@ def main():
|
|||
result = subprocess.run([str(relinker), "--skip-sce-module", str(source), str(output)],
|
||||
capture_output=True, text=True, timeout=20)
|
||||
assert result.returncode == 2 and error in result.stderr and not output.exists(), (name, result)
|
||||
|
||||
relocatable = main_fixture()
|
||||
struct.pack_into("<H", relocatable, 16, 1)
|
||||
source = Path(directory) / "relocatable.elf"
|
||||
output = Path(directory) / "relocatable.out"
|
||||
source.write_bytes(relocatable)
|
||||
result = subprocess.run([str(relinker), "--skip-sce-module", str(source), str(output)],
|
||||
capture_output=True, text=True, timeout=20)
|
||||
assert result.returncode == 2 and "ET_REL relocatable inputs are not supported" in result.stderr and not output.exists(), result
|
||||
|
||||
identification_cases(relinker, directory)
|
||||
structural_cases(relinker, directory)
|
||||
print("ELF header tests passed")
|
||||
|
|
|
|||
Loading…
Reference in New Issue