bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/29900] New: Partial Linking removes alignment from linker direct


From: address@hidden
Subject: [Bug ld/29900] New: Partial Linking removes alignment from linker directives
Date: Thu, 15 Dec 2022 09:49:48 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=29900

            Bug ID: 29900
           Summary: Partial Linking removes alignment from linker
                    directives
           Product: binutils
           Version: 2.39
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: denys.linke@ipg-automotive.com
  Target Milestone: ---

Hello everyone,

the following bug report is related to Windows and can be reproduced with the
mingw-w64 toolchain, that is available at:
https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-win32/seh/x86_64-8.1.0-release-win32-seh-rt_v6-rev0.7z/download
A Microsoft Visual Studio installation might be required as well.

All commands are considered to be done at cmd.exe.

First, extract mingw-w64 and append its bin folder (D:\mingw64\bin in my case)
to the PATH environment variable.
> set PATH=%PATH%"D:\mingw64\bin";
The potential bug can be reproduced with the following source code:
// aligned.c
int var;
int aligned_var __attribute__((aligned(32)));

Compile aligned.c, but dont run the linker
> gcc.exe -c -o aligned.o aligned.c
Do a partial linking step:
> ld.exe -r -o linked.o aligned.o
As far as I can tell it is not possible to check the symbol alignment with one
of the binutils tools. Therefore I use dumpbin.exe, which is part of MS Visual
Studio.

Extend the PATH environment variable in order to use dumpbin.exe. The actual
path depends on the installed Visual Studio version and might be different on
your system.
> set PATH=%PATH%"C:\Program Files (x86)\Microsoft Visual 
> Studio\Community\VC\Tools\MSVC\14.23.28105\bin\Hostx64\x64";
Now check the alignment of the symbols in the object file.
> dumpbin.exe /directives aligned.o
Microsoft (R) COFF/PE Dumper Version 14.23.28107.0
Copyright (C) Microsoft Corporation.  All rights reserved.

Dump of file aligned.o

File Type: COFF OBJECT

   Linker Directives
   -----------------
   -aligncomm:var,2
   -aligncomm:aligned_var,5

  Summary
           0 .bss
           0 .data
          30 .drectve
          20 .rdata$zzz
           0 .text

The dumpbin utility shows the alignment of the symbols var (2^2) and
aligned_var (2^5) like expected. Lets do the same check for the (partial)
linked object file.

> dumpbin.exe /directives linked.o
Microsoft (R) COFF/PE Dumper Version 14.23.28107.0
Copyright (C) Microsoft Corporation.  All rights reserved.

Dump of file linked.o

File Type: COFF OBJECT

  Summary
           0 .bss
           0 .data
          20 .rdata$zzz
           0 .text

As we can see the alignment information got lost at the partial linking step. I
think this is a bug, isn't it?

The behavior is the same for the latest Binutils (2.39 at this time) as well.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]