https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93180

            Bug ID: 93180
           Summary: const function pointers placed in a custom section are
                    causing that custom section to become writable
           Product: gcc
           Version: 7.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pskocik at gmail dot com
  Target Milestone: ---

__attribute((__section__("mysection"))) int const cx = -42;

(or with multiple const data variables in the `mysection` section) results in
assembly output containing

.section        mysection,"a",@progbits

Adding a const function pointer as in

#include <stdio.h>
__attribute((__section__("mysection"))) int (* const p)(char const*) = &puts;

causes the section to be mapped to a writable segment

.section        mysection,"aw",@progbits

Since the pointer is const, I think the section ought to remain read-only (on
clang it does).

Reply via email to