diff --git a/elf_reader.go b/elf_reader.go index 4d8d4bed9..04d57c50d 100644 --- a/elf_reader.go +++ b/elf_reader.go @@ -261,10 +261,6 @@ func (ec *elfCode) loadRelocations(relSections map[elf.SectionIndex]*elf.Section return fmt.Errorf("section %q: reference to %q in section %s: %w", section.Name, rel.Name, rel.Section, ErrNotSupported) } - if target.Flags&elf.SHF_STRINGS > 0 { - return fmt.Errorf("section %q: string is not stack allocated: %w", section.Name, ErrNotSupported) - } - target.references++ } diff --git a/elf_reader_test.go b/elf_reader_test.go index 2b51fba0d..b9f589bee 100644 --- a/elf_reader_test.go +++ b/elf_reader_test.go @@ -423,10 +423,22 @@ func TestLoadInvalidInitializedBTFMap(t *testing.T) { func TestStringSection(t *testing.T) { testutils.Files(t, testutils.Glob(t, "testdata/strings-*.elf"), func(t *testing.T, file string) { - _, err := LoadCollectionSpec(file) - t.Log(err) - if !errors.Is(err, ErrNotSupported) { - t.Error("References to a string section should be unsupported") + coll, err := LoadCollectionSpec(file) + if err != nil { + t.Fatal(err) + } + + strMap, found := coll.Maps[".rodata.str1.1"] + if !found { + t.Fatal("Unable to find map '.rodata.str1.1' in loaded collection") + } + + if !strMap.Freeze { + t.Fatal("Read only data maps should be frozen") + } + + if strMap.Flags != unix.BPF_F_RDONLY_PROG { + t.Fatal("Read only data maps should have the prog-read-only flag set") } }) }