I checked the elf-64 draft and I think you right. But I am not able to
understand why do we use p_paddr at all. Should we not be using p_vaddr
everywhere?
--
Nilay
On Tue, 18 Nov 2014, Romana, Alexandre via gem5-dev wrote:
Hi everybody,
Looks to me like there is a bug/typo in elf_loader.cc:
318 // Check to see if this segment contains the bss section.
319 if (phdr.p_paddr <= bssSecStart &&
320 phdr.p_paddr + phdr.p_memsz > bssSecStart &&
321 phdr.p_memsz - phdr.p_filesz > 0) {
322 bss.baseAddr = phdr.p_paddr + phdr.p_filesz;
323 bss.size = phdr.p_memsz - phdr.p_filesz;
324 bss.fileImage = NULL;
325 }
326
327 // Check to see if this is the text or data segment
328 if (phdr.p_vaddr <= textSecStart &&
329 phdr.p_vaddr + phdr.p_filesz > textSecStart) {
330 text.baseAddr = phdr.p_paddr;
331 text.size = phdr.p_filesz;
332 text.fileImage = fileData + phdr.p_offset;
333 } else if (phdr.p_vaddr <= dataSecStart &&
334 phdr.p_vaddr + phdr.p_filesz > dataSecStart) {
335 data.baseAddr = phdr.p_paddr;
336 data.size = phdr.p_filesz;
337 data.fileImage = fileData + phdr.p_offset;
338 } else {
339 // If it's none of the above but is loadable,
340 // load the filesize worth of data
341 Segment extra;
342 extra.baseAddr = phdr.p_paddr;
343 extra.size = phdr.p_filesz;
344 extra.fileImage = fileData + phdr.p_offset;
345 extraSegments.push_back(extra);
I guess nobody used so far the loader with the bss section mapped onto a
segment with different virtual and physical addresses…
To double check you can look at the bssSecStart definition:
bssSecStart = shdr.sh_addr;
sh_addr being the virtual address, I think we can safely assume there’s a typo
line 319-320, and I can submit a patch (changing 2 characters in the code),
or could anybody please explain why we are comparing virtual with physical
addresses here?
Thanks,
Alexandre
Texas Instruments France SAS, Immeuble Le Khapa, 65 Quai Georges Gorse, ZAC
Seguin Rives de Seine, 92100 Boulogne Billancourt. 036 420 040 R.C.S Nanterre.
Capital de EUR 12.654.784
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev