<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">malformed .o file crashes/hangs linker

&lt;rdar://problem/12501376&gt;

--- src/ld/parsers/macho_relocatable_file.cpp
+++ src/ld/parsers/macho_relocatable_file.cpp
@@ -822,6 +822,8 @@ template &lt;typename A&gt;
 const uint8_t* Atom&lt;A&gt;::contentPointer() const
 {
 	const macho_section&lt;P&gt;* sct = this-&gt;sect().machoSection();
+	if ( this-&gt;_objAddress &gt; sct-&gt;addr() + sct-&gt;size() )
+		throwf("malformed .o file, symbol has address 0x%0llX which is outside range of its section", (uint64_t)this-&gt;_objAddress);
 	uint32_t fileOffset = sct-&gt;offset() - sct-&gt;addr() + this-&gt;_objAddress;
 	return this-&gt;sect().file().fileContent()+fileOffset;
 }
</pre></body></html>