bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug gas/28262] New: Add warning when generating code in data section


From: dcmay at copper dot net
Subject: [Bug gas/28262] New: Add warning when generating code in data section
Date: Tue, 24 Aug 2021 21:27:06 +0000

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

            Bug ID: 28262
           Summary: Add warning when generating code in data section
           Product: binutils
           Version: 2.36.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gas
          Assignee: unassigned at sourceware dot org
          Reporter: dcmay at copper dot net
  Target Milestone: ---

If assembler code exists within a section that does not have a flags argument,
and does not have a "well known" name (like ".init" or ".text"), it is
assembled and silently placed within a data section.

Per 7.85, "If the section name is not recognized, the default will be for the
section to be loaded and writable."

ld will happily link the code, and the code will execute; but due to changes in
pr26850, gdb will no longer work properly with the resulting executable.

gas should warn about making this default assumption that a section containing
valid code is not being considered executable, but is considered modifiable
data.

If the code is a stub intended to be copied elsewhere before it is executed,
then the warning is trivially avoided by adding an "r" flag.

If the code is a stub intended to be modified at runtime before it is executed,
then the warning is trivially avoided by adding a "d" flag.

If the code is intended for direct execution, but is in a section named other
than .init, .text etc, then the warning is likewise avoided by added an "x"
flag.

The warning would only be emitted in the case where a section contains
executable code, has no flag(s), and is not named .init, .text, or any other
special name recognized by gas.

This would serve as a reminder that even though the code is being compiled, it
is being considered data.

As a side note, it seems undesirable for ANY compiled code to be considered
writable as a default. At best, it should probably default to "r" read-only.
Self modifying code should be considered the exception, not the norm.

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

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]