[PATCH] winegcc: Align sections in PE files to page size.

Rémi Bernon rbernon at codeweavers.com
Mon Jul 13 10:39:30 CDT 2020

On 2020-07-13 17:33, Martin Storsjö wrote:
> On Mon, 13 Jul 2020, Rémi Bernon wrote:
>> This makes sure it will be possible to mmap the section directly instead
>> of having to copy them. It then also makes perf able to figure the code
>> origin for Wine modules.
>> Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
>> ---
>> I'm resending just this one as I am now trying to upstream PE support
>> directly in Linux perf. This should still be useful to avoid copying
>> sections when Wine modules are loaded.
>> tools/winegcc/winegcc.c | 3 +++
>> 1 file changed, 3 insertions(+)
>> diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c
>> index 29c1b0549d3..24da839fd83 100644
>> --- a/tools/winegcc/winegcc.c
>> +++ b/tools/winegcc/winegcc.c
>> @@ -547,6 +547,9 @@ static strarray *get_link_args( struct options 
>> *opts, const char *output_name )
>>         else if (!opts->strip)
>>             strarray_add(link_args, "-Wl,-debug:dwarf");
>> +        if (!try_link( opts->prefix, link_args, 
>> "-Wl,--file-alignment:0x1000"))
>> +            strarray_add( link_args, "-Wl,--file-alignment:0x1000" );
>> +
> Am I reading this correctly that it checks whether the linker supports 
> the option, and only uses it in that case?
> The LLD mingw frontend doesn't support this option at the moment I 
> believe, but it shouldn't be hard to add support for it.
> The option format seems a bit confusing though.
> The section the option is added into, for PLATFORM_WINDOWS, is for 
> building with MSVC tools (or clang in MSVC mode) with a link.exe style 
> linker (in practice, lld-link).
> In that case, the option should be "-filealign:<n>" (passed via a 
> compiler driver, so "-Wl,-filealign:<n>"), while the mingw style linker 
> option (for the section further up) would be "-Wl,--file-alignment,<n>".
> And even if it actually would work, with the argument separated with a 
> colon, instead of as a separate argument (separated with a comma when 
> using -Wl), I'd prefer if you'd use the more standard form without 
> colons, as the LLD mingw frontend at least doesn't handle using colons 
> as separator there.
> // Martin

Yes sorry, I'll move that to the PLATFORM_MINGW part, with comma as 
separator. I don't think the PLATFORM_WINDOWS case matters much as it's 
not supposed to be loaded with the Wine loader IIRC.
Rémi Bernon <rbernon at codeweavers.com>

More information about the wine-devel mailing list