On 3/4/20 10:00 AM, Richard Biener wrote:
On Tue, Mar 3, 2020 at 5:41 PM Egeyar Bagcioglu
<egeyar.bagcio...@oracle.com> wrote:
This patch is for .GCC.command.line sections in LTO objects to be copied
into the final objects as in the following example:

[egeyar@localhost lto]$ gcc -flto -O3 demo.c -c -g --record-gcc-command-line
[egeyar@localhost lto]$ gcc -flto -O2 demo2.c -c -g --record-gcc-command-line 
-DFORTIFY=2
[egeyar@localhost lto]$ gcc demo.o demo2.o -o a.out
[egeyar@localhost lto]$ readelf -p .GCC.command.line a.out

String dump of section '.GCC.command.line':
   [     0]  10.0.1 20200227 (experimental) : gcc -flto -O3 demo.c -c -g 
--record-gcc-command-line
   [    56]  10.0.1 20200227 (experimental) : gcc -flto -O2 demo2.c -c -g 
--record-gcc-command-line -DFORTIFY=2
--record-gcc-command-line is not a FSF GCC option, there's
-frecord-gcc-switches though which
(also) populates .GCC.command.line

Right. This is also necessary for preserving the outcome of -frecord-gcc-switches option and that issue is reported to me by Martin Liska.

OK.

Thanks Richard.

I do not have write-access to the GCC repo. I'd be glad if someone commits it for me.

Regards
Egeyar


Thanks,
Richard.

Regards
Egeyar

libiberty:
2020-02-27  Egeyar Bagcioglu  <egeyar.bagcio...@oracle.com>

         * simple-object.c (handle_lto_debug_sections): Name
         ".GCC.command.line" among debug sections to be copied over
         from lto objects.
---
  libiberty/simple-object.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/libiberty/simple-object.c b/libiberty/simple-object.c
index d9c648a..3b3ca9c 100644
--- a/libiberty/simple-object.c
+++ b/libiberty/simple-object.c
@@ -298,6 +298,9 @@ handle_lto_debug_sections (const char *name, int rename)
       COMDAT sections in objects produced by GCC.  */
    else if (strcmp (name, ".comment") == 0)
      return strcpy (newname, name);
+  /* Copy over .GCC.command.line section under the same name if present.  */
+  else if (strcmp (name, ".GCC.command.line") == 0)
+    return strcpy (newname, name);
    free (newname);
    return NULL;
  }
--
1.8.3.1


Reply via email to