Constants are presently created in the initialized read-write section (ie .data 
section) whenever they should be created in the initialized read-only section 
(ie .rodata section, as are the implicit string constants).

An exemple:
package Foo is

   Bar : constant Integer := 1;

end Foo;

$ gcc -c foo.adb
$ nm foo.o
00000000 D foo__bar
00000001 C foo_E

When it should be:
$nm foo.o
00000000 R foo__bar
00000001 C foo_E

This would have a good impact since program like below would receive segfault 
(maybe the Runtime would raise exception):
procedure foo is
   A : constant Integer := 1;
   B : Integer;
   for B'Address use A'Address;
begin
   B := 2;
end foo;
Which is BAD as you probably agree.

Note also: implicit String constants as in :
   Put("Foo Bar");
are put in the read-only section when explicit String constants as in Bar :
   constant String := "Foo Bar";
are put in the read-write section.

-- 
           Summary: Put constants read-only on ELF platforms
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: ada
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jc at apinc dot org
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i486-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19035

Reply via email to