diff mbox

[FFmpeg-devel] Mark .rodata section as read only in COFF object file

Message ID MWHPR21MB0750B0A7647C679133C8BBE1E2840@MWHPR21MB0750.namprd21.prod.outlook.com
State Superseded
Headers show

Commit Message

Tom Tan Jan. 10, 2019, 8:14 p.m. UTC
.rodata directive from GAS assembly produces .rodata as read/write for COFF
object file by default (object file format for Windows), but read only for
ELF. This change marks it as read only explicitly for COFF.

The issue happens when building Chromium for Windows ARM64, with FFmpeg.

---
 libavutil/aarch64/asm.S | 2 ++
 1 file changed, 2 insertions(+)

Comments

Carl Eugen Hoyos Jan. 11, 2019, 1:07 p.m. UTC | #1
2019-01-10 21:14 GMT+01:00, Tom Tan <Tom.Tan@microsoft.com>:
> .rodata directive from GAS assembly produces .rodata as read/write for COFF
> object file by default (object file format for Windows), but read only for
> ELF. This change marks it as read only explicitly for COFF.
>
> The issue happens when building Chromium for Windows ARM64, with FFmpeg.

Does this issue only apply to arm64 or also 32bit arm?

Carl Eugen
Tom Tan Jan. 11, 2019, 7:38 p.m. UTC | #2
Thanks Carl. Martin made a better fix when porting this to libav which uses .rdata as section name instead of .rodata with explicit read-only property. .rdata is read-only in COFF by default. I updated my patch accordingly, thanks Martin.

Yes, this applies to 32-bit arm for Windows, the new patch includes this update. This also affects Windows x86/x64, but this has already been handled as below macro from FFmpeg\libavutil\x86\x86inc.asm.

%macro SECTION_RODATA 0-1 16
    %ifidn __OUTPUT_FORMAT__,aout
        SECTION .text
    %elifidn __OUTPUT_FORMAT__,coff
        SECTION .text
    %elifidn __OUTPUT_FORMAT__,win32
        SECTION .rdata align=%1
    %elif WIN64
        SECTION .rdata align=%1
    %else
        SECTION .rodata align=%1
    %endif
%endmacro

-----Original Message-----
From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Carl Eugen Hoyos

Sent: Friday, January 11, 2019 5:07 AM
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH] Mark .rodata section as read only in COFF object file

2019-01-10 21:14 GMT+01:00, Tom Tan <Tom.Tan@microsoft.com>:
> .rodata directive from GAS assembly produces .rodata as read/write for 

> COFF object file by default (object file format for Windows), but read 

> only for ELF. This change marks it as read only explicitly for COFF.

>

> The issue happens when building Chromium for Windows ARM64, with FFmpeg.


Does this issue only apply to arm64 or also 32bit arm?

Carl Eugen
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
diff mbox

Patch

diff --git a/libavutil/aarch64/asm.S b/libavutil/aarch64/asm.S
index fd32bf784e..abc2f69f43 100644
--- a/libavutil/aarch64/asm.S
+++ b/libavutil/aarch64/asm.S
@@ -63,6 +63,8 @@  ELF     .size   \name, . - \name
 .else
         .section        .rodata
 .endif
+#elif defined(_WIN32)
+        .section        .rodata, "r"
 #elif !defined(__MACH__)
         .section        .rodata
 #else