diff --git a/chb/app/CHVersion.py b/chb/app/CHVersion.py index b37682b7..f7b0a210 100644 --- a/chb/app/CHVersion.py +++ b/chb/app/CHVersion.py @@ -1 +1 @@ -chbversion: str = "0.3.0-20250825" +chbversion: str = "0.3.0-20250826" diff --git a/chb/cmdline/XComparison.py b/chb/cmdline/XComparison.py index e7f1f189..c5a7bec3 100644 --- a/chb/cmdline/XComparison.py +++ b/chb/cmdline/XComparison.py @@ -347,6 +347,36 @@ def new_userdata(self) -> Dict[str, Any]: seg["status"] = "new" sectionheaders["segment_" + str(ph2.index)] = seg result["section-headers"] = sectionheaders + elif len(self.newsections) == 0 and len(self.newcode) == 1: + newaddr = self.newcode[0][0] + newsize = str(int(self.newcode[0][1], 16) - int(newaddr, 16)) + sectionheaders = {} + for (name, (optsh1, optsh2)) in self.sectionheaderpairs.items(): + if optsh1 is not None and optsh2 is not None: + if ( + (optsh1.vaddr == optsh2.vaddr) + and (optsh1.size != optsh2.size)): + sec1offset = optsh1.get_default_attribute_value( + "sh_offset", "0x0") + offsetdiff = int(optsh1.vaddr, 16) - int(sec1offset, 16) + + sec1: Dict[str, str] = {} + sec1["addr"] = optsh1.vaddr + sec1["size"] = optsh1.size + sec1["offset"] = optsh1.get_default_attribute_value( + "sh_offset", "0x0") + sectionheaders[name] = sec1 + + sec2offset = str(int(newaddr, 16) - offsetdiff) + sec2: Dict[str, str] = {} + sec2["addr"] = newaddr + sec2["size"] = newsize + sec2["type"] = "0x1" + sec2["flags"] = "0x6" + sec2["status"] = "new" + sec2["offset"] = sec2offset + sectionheaders[".trampolinecode"] = sec2 + result["section-headers"] = sectionheaders return result def prepare_report(self) -> str: diff --git a/chb/cmdline/relationalcmds.py b/chb/cmdline/relationalcmds.py index 9775687e..725c46a3 100644 --- a/chb/cmdline/relationalcmds.py +++ b/chb/cmdline/relationalcmds.py @@ -217,7 +217,7 @@ def relational_prepare_command(args: argparse.Namespace) -> NoReturn: with open(save_aux_userdata + ".json", "w") as fp: json.dump(userhints.hints, fp, indent=2) - if len(xcomparison.newsegments) > 0: + if len(xcomparison.newsegments) > 0 or len(xcomparison.newcode) > 0: tmpfilename = os.path.join(path2, "tmp_userdata.json") tmpuserdata: Dict[str, Any] = {} tmpuserdata["userdata"] = userhints.hints