Skip to content

Commit 7af630b

Browse files
lewurmzapster
authored andcommitted
MachORelocationElement: Always verify symbol name lookup
1 parent 11ac7de commit 7af630b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/macho/MachORelocationElement.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
import java.util.Set;
3131
import java.util.TreeMap;
3232

33-
import jdk.graal.compiler.core.common.NumUtil;
34-
3533
import com.oracle.objectfile.BuildDependency;
3634
import com.oracle.objectfile.LayoutDecisionMap;
3735
import com.oracle.objectfile.ObjectFile;
@@ -45,6 +43,8 @@
4543
import com.oracle.objectfile.io.OutputAssembler;
4644
import com.oracle.objectfile.macho.MachOObjectFile.MachOSection;
4745
import com.oracle.objectfile.macho.MachOObjectFile.Segment64Command;
46+
47+
import jdk.graal.compiler.core.common.NumUtil;
4848
import jdk.graal.compiler.debug.GraalError;
4949

5050
class MachORelocationElement extends MachOObjectFile.LinkEditElement {
@@ -268,7 +268,9 @@ private MachORelocationInfo(MachORelocationElement containingElement, MachOSecti
268268
// FIXME: also allow section numbers here, for non-extern symbols
269269
// FIXME: encode R_ABS symbol number
270270
this.sym = symtab.getSymbol(symbolName);
271-
assert this.sym != null : "could not find symbol " + symbolName;
271+
if (this.sym == null) {
272+
throw new IllegalArgumentException("Could not find symbol " + symbolName);
273+
}
272274
// if the symbol is defined in the same file, i.e. locally, we have a target section
273275
assert !asLocalReloc || this.sym.isDefined();
274276
this.targetSection = asLocalReloc ? (MachOSection) this.sym.getDefinedSection() : null;

0 commit comments

Comments
 (0)