https://sourceware.org/bugzilla/show_bug.cgi?id=16685

            Bug ID: 16685
           Summary: Read-only data sections should not be executable
           Product: binutils
           Version: unspecified
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: zackw at panix dot com

The usual ELF linker scripts lump a variety of "read-only data" sections into
the same program segment as the actual code ("text"), thus allowing data in
those sections to be executed, if by chance the PC is misdirected there.  As a
somewhat silly demonstration, compile and run

    const char main[] = "1\300\303";

on an x86/elf system, and it will execute successfully!  (Remove the 'const'
and it will crash, because modifiable data is in a different segment which does
not have execute permission.)

In principle, fixing this is as simple as defining an additional LOAD segment
in the linker script, and moving all of the sections that contain read-only
data but not machine code there.  The details might get a little hairy.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

_______________________________________________
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils

Reply via email to