From f2be601a137a145e7b56bb8c40768820d8cdd536 Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Mon, 3 Feb 2020 20:57:12 +0100 Subject: [PATCH] Check "left" boundary as well in `isLocationSuitable` "fixed" and "aligned" location checking advanced the target location to places regardless of the associated free space, potentially breaking the assumption that the location was always further in memory than the free space's base. Rather than adding more code to try keeping that assumption true, harden `isLocationSuitable` and handle that case as well. --- src/link/assign.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/link/assign.c b/src/link/assign.c index c36bf735..0c4e8083 100644 --- a/src/link/assign.c +++ b/src/link/assign.c @@ -135,6 +135,8 @@ static bool isLocationSuitable(struct Section const *section, if (section->isAlignFixed && location->address & section->alignMask) return false; + if (location->address < freeSpace->address) + return false; return location->address + section->size <= freeSpace->address + freeSpace->size; }