Skip to content

Commit

Permalink
elf_reader: freeze all data sections with .rodata* prefix
Browse files Browse the repository at this point in the history
LoadCollectionSpecFromReader marks all .rodata* sections as data sections,
but loadDataSections() only freezes '.rodata'.

Signed-off-by: Timo Beckers <timo@isovalent.com>
  • Loading branch information
ti-mo committed May 23, 2022
1 parent 1e1f08c commit 88c2d0c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions elf_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -1046,11 +1046,11 @@ func (ec *elfCode) loadDataSections(maps map[string]*MapSpec) error {
BTF: ec.btf,
}

switch sec.Name {
case ".rodata":
switch n := sec.Name; {
case strings.HasPrefix(n, ".rodata"):
mapSpec.Flags = unix.BPF_F_RDONLY_PROG
mapSpec.Freeze = true
case ".bss":
case n == ".bss":
// The kernel already zero-initializes the map
mapSpec.Contents = nil
}
Expand Down

0 comments on commit 88c2d0c

Please sign in to comment.