|
@@ -742,6 +742,24 @@ bpf_object__init_maps(struct bpf_object *obj)
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static bool section_have_execinstr(struct bpf_object *obj, int idx)
|
|
|
|
+{
|
|
|
|
+ Elf_Scn *scn;
|
|
|
|
+ GElf_Shdr sh;
|
|
|
|
+
|
|
|
|
+ scn = elf_getscn(obj->efile.elf, idx);
|
|
|
|
+ if (!scn)
|
|
|
|
+ return false;
|
|
|
|
+
|
|
|
|
+ if (gelf_getshdr(scn, &sh) != &sh)
|
|
|
|
+ return false;
|
|
|
|
+
|
|
|
|
+ if (sh.sh_flags & SHF_EXECINSTR)
|
|
|
|
+ return true;
|
|
|
|
+
|
|
|
|
+ return false;
|
|
|
|
+}
|
|
|
|
+
|
|
static int bpf_object__elf_collect(struct bpf_object *obj)
|
|
static int bpf_object__elf_collect(struct bpf_object *obj)
|
|
{
|
|
{
|
|
Elf *elf = obj->efile.elf;
|
|
Elf *elf = obj->efile.elf;
|
|
@@ -825,6 +843,14 @@ static int bpf_object__elf_collect(struct bpf_object *obj)
|
|
} else if (sh.sh_type == SHT_REL) {
|
|
} else if (sh.sh_type == SHT_REL) {
|
|
void *reloc = obj->efile.reloc;
|
|
void *reloc = obj->efile.reloc;
|
|
int nr_reloc = obj->efile.nr_reloc + 1;
|
|
int nr_reloc = obj->efile.nr_reloc + 1;
|
|
|
|
+ int sec = sh.sh_info; /* points to other section */
|
|
|
|
+
|
|
|
|
+ /* Only do relo for section with exec instructions */
|
|
|
|
+ if (!section_have_execinstr(obj, sec)) {
|
|
|
|
+ pr_debug("skip relo %s(%d) for section(%d)\n",
|
|
|
|
+ name, idx, sec);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
|
|
reloc = realloc(reloc,
|
|
reloc = realloc(reloc,
|
|
sizeof(*obj->efile.reloc) * nr_reloc);
|
|
sizeof(*obj->efile.reloc) * nr_reloc);
|