bug-binutils
[Top][All Lists]
Advanced

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

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


From: nickc at redhat dot com
Subject: [Bug gas/28262] Add warning when generating code in data section
Date: Mon, 06 Sep 2021 11:51:01 +0000

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

--- Comment #4 from Nick Clifton <nickc at redhat dot com> ---
(In reply to Dietmar May from comment #2)

> This assembled, linked, ran 

Ran in what environment ?

I agree that the processor itself will happily attempt to execute anything that
it is pointed at, regardless of whether it is data or assembled code.  But the
point is that any reasonable operating system should never ask the processor to
execute data.  So how did the assembled-into-a-data-section code get executed ?


> However, perhaps because of the layout in the ld file, 

Do you mean the linker script ?  Maybe this is the problem.  Maybe the script
is putting data input sections into a executable output section (or segment).


> Me, I'm still confused as to why any section that contains only assembler
> code would default to be data. Seems like the default for a section should
> depend on what that section contains ...

Which would require that the assembler looks ahead through the input source in
an attempt to determine if instructions or data are going to be placed into the
just-declared section.

(There is also a general principle that if you are creating hand written
assembler code then you do need to know what you are doing.  Not that the
assembler can't be helpful per se, but too much hand holding is going make the
assembler a lot slower...)

-- 
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]