def gd_patch(self, line): # addr of gd should be the top of .data section, so lookup where this section is line = line.strip() global patches if self._data_loc == -1: (self._data_loc, end) = pure_utils.get_section_location(self.cc, self.elf, ".data") if ("frama_c_tweaks" not in self.path) and \ (re.match('register volatile gd_t \*gd asm \("r9"\);', line) is not None): n = patches.get("gd", 0) patches["gd"] = n + 1 return "gd_t *gd; //@ volatile gd reads read_gd writes write_gd;\n" elif ("frama_c_tweaks" in self.path) and \ (re.match('register volatile gd_t \*gd asm \("r9"\);', line) is not None): n = patches.get("gd", 0) patches["gd"] = n + 1 return "gd_t *gd = 0x%x; //@ volatile gd reads read_gd writes write_gd;\n" % \ self._data_loc else: return line + "\n"
def get_section_location(name, stage): elf = stage.elf return pure_utils.get_section_location(elf, name)
def get_section_location(name, stage): cc = Main.cc elf = stage.elf return pure_utils.get_section_location(cc, elf, name)
def get_section_location(name, stage): cc = Main.cc elf = Main.get_config("stage_elf", stage) return pure_utils.get_section_location(cc, elf, name)