* make the string data of pchar constants read-only (mantis #30666)

git-svn-id: trunk@34594 -
This commit is contained in:
Jonas Maebe 2016-10-02 12:56:40 +00:00
parent 559a5982f9
commit de60bfab9c
3 changed files with 31 additions and 1 deletions

1
.gitattributes vendored
View File

@ -15236,6 +15236,7 @@ tests/webtbs/tw30570.pp svneol=native#text/plain
tests/webtbs/tw30572.pp svneol=native#text/plain
tests/webtbs/tw3063.pp svneol=native#text/plain
tests/webtbs/tw3064.pp svneol=native#text/plain
tests/webtbs/tw30666.pp svneol=native#text/plain
tests/webtbs/tw3073.pp svneol=native#text/plain
tests/webtbs/tw3082.pp svneol=native#text/plain
tests/webtbs/tw3083.pp svneol=native#text/plain

View File

@ -816,7 +816,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
begin
{ create a tcb for the string data (it's placed in a separate
asmlist) }
ftcb.start_internal_data_builder(fdatalist,sec_rodata,'',datatcb,ll);
ftcb.start_internal_data_builder(fdatalist,sec_rodata_norel,'',datatcb,ll);
if node.nodetype=stringconstn then
varalign:=size_2_align(tstringconstnode(node).len)
else

29
tests/webtbs/tw30666.pp Normal file
View File

@ -0,0 +1,29 @@
{ %target=linux,darwin,freebsd,openbsd,netbsd,aix,solaris,android,win32,win64 }
{$mode objfpc}
uses
sysutils;
procedure foo;
var
s: PChar = 'PChar';
b: boolean;
begin
b:=false;
try
s[0] := 'a';
except
on e: exception do
begin
if e is EAccessViolation then
b:=true;
end;
end;
if not b then
halt(1);
end;
begin
foo;
end.