Skip to content
This repository was archived by the owner on Jan 25, 2022. It is now read-only.

Commit ebf54c4

Browse files
authored
Merge pull request #4 from HexRabbit/glibc-elf-load-support
Support glibc statically linked ELF
2 parents 964a40d + 6f64e9d commit ebf54c4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

emu-rv32i.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,7 +2053,7 @@ int main(int argc, char** argv)
20532053
}
20542054
}
20552055

2056-
/* set .text segment as the base address */
2056+
/* set .text section as the base address */
20572057
scn = NULL;
20582058
size_t shstrndx;
20592059
elf_getshdrstrndx(elf, &shstrndx);
@@ -2080,7 +2080,9 @@ int main(int argc, char** argv)
20802080
scn = NULL;
20812081
while ((scn = elf_nextscn(elf, scn)) != NULL) {
20822082
gelf_getshdr(scn, &shdr);
2083-
if (shdr.sh_type == SHT_PROGBITS) {
2083+
2084+
/* filter NULL address sections and .bss */
2085+
if (shdr.sh_addr && shdr.sh_type != SHT_NOBITS) {
20842086
Elf_Data *data = elf_getdata(scn, NULL);
20852087
if (shdr.sh_addr >= ram_start) {
20862088
for (size_t i = 0; i < shdr.sh_size; i++) {

0 commit comments

Comments
 (0)