Skip to content

Commit

Permalink
asm/x86_64-xlate.pl: handle .section .rodata directive.
Browse files Browse the repository at this point in the history
  • Loading branch information
dot-asm committed Mar 16, 2024
1 parent 0d46eef commit dae1f94
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/asm/x86_64-xlate.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,10 @@
if ($flavour eq "macosx") { $self->{value} = ".mod_init_func"; }
elsif ($flavour eq "mingw64") { $self->{value} = ".section\t.ctors"; }
}
if (!$elf && $current_segment eq ".rodata") {
if ($flavour eq "macosx") { $self->{value} = ".section\t__TEXT,__const"; }
elsif ($flavour eq "mingw64") { $self->{value} = ".section\t.rdata"; }
}
} elsif ($dir =~ /\.(text|data)/) {
$current_segment=".$1";
} elsif ($dir =~ /\.hidden/) {
Expand Down Expand Up @@ -1177,20 +1181,21 @@
/\.section/ && do { my $v=undef;
$$line =~ s/([^,]*).*/$1/;
$$line = ".CRT\$XCU" if ($$line eq ".init");
$$line = ".rdata" if ($$line eq ".rodata");
my %align = ( p=>4, x=>8, r=>256);
if ($nasm) {
$v="section $$line";
if ($$line=~/\.([px])data/) {
$v.=" rdata align=";
$v.=$1 eq "p"? 4 : 8;
if ($$line=~/\.([pxr])data/) {
$v.=" rdata align=$align{$1}";
} elsif ($$line=~/\.CRT\$/i) {
$v.=" rdata align=8";
}
} else {
$v="$current_segment\tENDS\n" if ($current_segment);
$v.="$$line\tSEGMENT";
if ($$line=~/\.([px])data/) {
if ($$line=~/\.([pxr])data/) {
$v.=" READONLY";
$v.=" ALIGN(".($1 eq "p" ? 4 : 8).")" if ($masm>=$masmref);
$v.=" ALIGN($align{$1})" if ($masm>=$masmref);
} elsif ($$line=~/\.CRT\$/i) {
$v.=" READONLY ";
$v.=$masm>=$masmref ? "ALIGN(8)" : "DWORD";
Expand Down

0 comments on commit dae1f94

Please sign in to comment.