MCPcopy Create free account
hub / github.com/GJDuck/e9patch / parseBinary

Method parseBinary

src/e9tool/e9frontend.cpp:1552–1571  ·  view source on GitHub ↗

* Parse a binary. */

Source from the content-addressed store, hash-verified

1550 * Parse a binary.
1551 */
1552ELF *e9tool::parseBinary(const char *filename, intptr_t base)
1553{
1554 int fd = open(filename, O_RDONLY, 0);
1555 if (fd < 0)
1556 error("failed to open file \"%s\" for reading: %s", filename,
1557 strerror(errno));
1558 char c;
1559 if (read(fd, &c, sizeof(char)) != 1)
1560 error("failed to read file \"%s\": %s", filename, strerror(errno));
1561 close(fd);
1562
1563 switch (c)
1564 {
1565 case 'E':
1566 default:
1567 return parseELF(filename, base);
1568 case 'M':
1569 return parsePE(filename);
1570 }
1571}
1572
1573/*
1574 * Free an ELF file object.

Callers

nothing calls this directly

Calls 6

openFunction · 0.85
errorFunction · 0.85
strerrorFunction · 0.85
readFunction · 0.85
closeFunction · 0.85
parsePEFunction · 0.85

Tested by

no test coverage detected