Skip to main content

romStringEnd, romClassEnd, romCBEnd in preloader.c

2 replies [Last post]
gyu
Offline
Joined: 2007-06-03

Hello,

I have a question about setting romStringEnd, romClassEnd, and romCBEnd in preloader.c.

These variables are set in CVMmemBssWriteNotify in preloader.c like followings:

romStringStart = (CVMUint32)CVM_ROMStrings;
romStringEnd = (CVMUint32)&CVM_ROMStrings[CVM_nROMStrings] +
sizeof(struct java_lang_String);
...
romClassStart = (CVMUint32)CVM_ROMClasses;
romClassEnd = (CVMUint32)&CVM_ROMClasses[CVM_nROMClasses] +
sizeof(struct java_lang_Class);
romCBStart = (CVMUint32)CVM_ROMClassBlocks;
romCBEnd = (CVMUint32)&CVM_ROMClassBlocks[CVM_nROMClasses] +
sizeof(struct java_lang_String);
romPkgStart = (CVMUint32)CVM_ROMpackages;
romPkgEnd = (CVMUint32)(CVM_ROMpackages + CVM_nROMpackages + 1);
romPkgHashStart = (CVMUint32)CVM_pkgHashtable;
romPkgHashEnd = (CVMUint32)(CVM_pkgHashtable + NPACKAGEHASH + 1);
methodTypeHashStart = (CVMUint32)CVMMethodTypeHash;
methodTypeHashEnd = (CVMUint32)(CVMMethodTypeHash +
NMETHODTYPEHASH + 1);
memberNameHashStart = (CVMUint32)CVMMemberNameHash;
memberNameHashEnd = (CVMUint32)(CVMMemberNameHash + NMEMBERNAMEHASH + 1);

xxxEnd is set to not real end, but next to real end. Is it right?

If so, in the same function (i.e., CVMmemBssWriteNotify).

else if (waddr >= romStringStart && waddr <= romStringEnd) {
sectionName = "Rom String";
p = (waddr - ALIGNED(romStringStart)) / 4096 - 1;
if (strmap[p] == 0) {
strmap[p] = 0x1;
strdp ++;
}
} else if (waddr >= romClassStart && waddr <= romClassEnd) {
sectionName = "Rom Class";
p = (waddr - ALIGNED(romClassStart)) / 4096 -1;
if (clmap[p] == 0) {
clmap[p] = 0x1;
cldp ++;
}
} else if (waddr >= romCBStart && waddr <= romCBEnd) {
sectionName = "Rom CB";
p = (waddr - ALIGNED(romCBStart)) / 4096 - 1;
if (cbmap[p] == 0) {
cbmap[p] = 0x1;
cbdp ++;
}

all the end range is checked with "<=", not "<".

Then if there is a write (maybe, it cannot be happen) to CVM_ROMStrings[CVM-nROMStrings], it does not actually write to CVM_ROMStrings array. But it is considered as writing to CVM_ROMStrings array.

Message was edited by: gyu

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
cjplummer
Offline
Joined: 2006-10-16

I think you are right. It looks like end - start is suppose to give you the size of the section, and end is the address just after the last byte of the section. In that case, when checking which section waddr is in, we should be using waddr < end, not waddr <= end.

Chris

gyu
Offline
Joined: 2007-06-03

My original message is not displayed in this board.
Here is my original message. ( It still has distorted in source code. )
I try to delete my misrepresented mesage.
I cannot find delete button.
I am sorry.

> Hello,
>
> I have a question about setting romStringEnd,
> romClassEnd, and romCBEnd in preloader.c.
>
> These variables are set in CVMmemBssWriteNotify in
> preloader.c like followings:
>
> romStringStart = (CVMUint32)CVM_ROMStrings;
> romStringEnd =
> (CVMUint32)&CVM_ROMStrings[[b]CVM_nROMStrings[/b]] +
> sizeof(struct
> java_lang_String);
> ...
> romClassStart = (CVMUint32)CVM_ROMClasses;
> romClassEnd =
> (CVMUint32)&CVM_ROMClasses[[b]CVM_nROMClasses[/b]]
> +
> sizeof(struct
> java_lang_Class);
> romCBStart = (CVMUint32)CVM_ROMClassBlocks;
> romCBEnd =
> (CVMUint32)&CVM_ROMClassBlocks[[b]CVM_nROMClasses[/b]]
> +
> sizeof(struct
> java_lang_String);
> romPkgStart = (CVMUint32)CVM_ROMpackages;
> romPkgEnd = (CVMUint32)(CVM_ROMpackages +
> CVM_nROMpackages [b]+ 1[/b]);
> romPkgHashStart =
> (CVMUint32)CVM_pkgHashtable;
> romPkgHashEnd = (CVMUint32)(CVM_pkgHashtable +
> NPACKAGEHASH +[b] 1[/b]);
> methodTypeHashStart =
> (CVMUint32)CVMMethodTypeHash;
> methodTypeHashEnd =
> (CVMUint32)(CVMMethodTypeHash +
>
> METHODTYPEHASH [b]+ 1[/b]);
> memberNameHashStart =
> (CVMUint32)CVMMemberNameHash;
> memberNameHashEnd =
> (CVMUint32)(CVMMemberNameHash +
>
> MEMBERNAMEHASH [b]+ 1[/b]);
>
> xxxEnd is set to not real end, but next to real end.
> Is it right?
>
> If so, in the same function (i.e.,
> CVMmemBssWriteNotify).
>
> else if (waddr >= romStringStart && waddr <= romStringEnd) {
> sectionName = "Rom String";
> p = (waddr - ALIGNED(romStringStart)) / 4096 - 1;
> if (strmap[p] == 0) {
> strmap[p] = 0x1;
> strdp ++;
> }
> } else if (waddr >= romClassStart && waddr
> [b]<=[/b] romClassEnd) {
> sectionName = "Rom Class";
> p = (waddr - ALIGNED(romClassStart)) / 4096 -1;
> if (clmap[p] == 0) {
> clmap[p] = 0x1;
> cldp ++;
> }
> } else if (waddr >= romCBStart && waddr [b]<=[/b]
> romCBEnd) {
> sectionName = "Rom CB";
> p = (waddr - ALIGNED(romCBStart)) / 4096 - 1;
> if (cbmap[p] == 0) {
> cbmap[p] = 0x1;
> cbdp ++;
> }
>
> all the end range is checked with "<=", not "<".
>
> Then if there is a write (maybe, it cannot be happen)
> to CVM_ROMStrings[CVM-nROMStrings], it does not
> actually write to CVM_ROMStrings array. But it is
> considered as writing to CVM_ROMStrings array.
>
> Message was edited by: gyu