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

Re: [Minios-devel] [UNIKRAFT PATCH v3 4/4] build: add debug symbols and comment sections to all linkers



I agree with the general idea of the patch, but I suggest to name the file common.lds.h instead of common-lds.h (and I think from our quick offline discussion, you agree).

On 5/15/19 3:53 PM, Yuri Volchkov wrote:
Gcc generates them anyways. Let's take a little control over what it
does.

Signed-off-by: Yuri Volchkov <yuri.volchkov@xxxxxxxxx>
---
  plat/common/include/common-lds.h | 67 ++++++++++++++++++++++++++++++++
  plat/kvm/arm/link64.lds.S        |  5 +++
  plat/kvm/x86/link64.lds.S        |  5 +++
  plat/xen/arm/link32.lds.S        |  4 ++
  plat/xen/x86/link64.lds.S        |  6 +++
  5 files changed, 87 insertions(+)
  create mode 100644 plat/common/include/common-lds.h

diff --git a/plat/common/include/common-lds.h b/plat/common/include/common-lds.h
new file mode 100644
index 00000000..8672b6ff
--- /dev/null
+++ b/plat/common/include/common-lds.h
@@ -0,0 +1,67 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Copyright (c) 2019, NEC Laboratories Europe GmbH, NEC Corporation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __UK_COMMON_LDS_H
+#define __UK_COMMON_LDS_H
+
+/* DWARF debug sections.  Symbols in the DWARF debugging sections are
+ * relative to the beginning of the section so we begin them at 0.
+ */
+#define DEBUG_SYMBOLS                                                  \
+       /* DWARF 1 */                                                   \
+       .debug          0 : { *(.debug) }                               \
+       .line           0 : { *(.line) }                                \
+       /* GNU DWARF 1 extensions */                                    \
+       .debug_srcinfo  0 : { *(.debug_srcinfo) }                       \
+       .debug_sfnames  0 : { *(.debug_sfnames) }                       \
+       /* DWARF 1.1 and DWARF 2 */                                     \
+       .debug_aranges  0 : { *(.debug_aranges) }                       \
+       .debug_pubnames 0 : { *(.debug_pubnames) }                      \
+       /* DWARF 2 */                                                   \
+       .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }       \
+       .debug_abbrev   0 : { *(.debug_abbrev) }                        \
+       .debug_line     0 : { *(.debug_line .debug_line.* .debug_line_end ) } \
+       .debug_frame    0 : { *(.debug_frame) }                         \
+       .debug_str      0 : { *(.debug_str) }                           \
+       .debug_loc      0 : { *(.debug_loc) }                           \
+       .debug_macinfo  0 : { *(.debug_macinfo) }                       \
+       /* SGI/MIPS DWARF 2 extensions */                               \
+       .debug_weaknames 0 : { *(.debug_weaknames) }                    \
+       .debug_funcnames 0 : { *(.debug_funcnames) }                    \
+       .debug_typenames 0 : { *(.debug_typenames) }                    \
+       .debug_varnames  0 : { *(.debug_varnames) }                     \
+       /* DWARF 3 */                                                   \
+       .debug_pubtypes 0 : { *(.debug_pubtypes) }                      \
+       .debug_ranges   0 : { *(.debug_ranges) }                        \
+       /* DWARF Extension.  */                                         \
+       .debug_macro    0 : { *(.debug_macro) }                         \
+       .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
+
+#endif /* __UK_COMMON_LDS_H */
diff --git a/plat/kvm/arm/link64.lds.S b/plat/kvm/arm/link64.lds.S
index 8157271b..2d4e49d4 100644
--- a/plat/kvm/arm/link64.lds.S
+++ b/plat/kvm/arm/link64.lds.S
@@ -32,6 +32,7 @@
   * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
   */
  #include <uk/arch/limits.h>
+#include <common-lds.h>
/* QEMU-AArch64 virt platform's ram base address */
  #define RAM_BASE_ADDR 0x40000000
@@ -152,5 +153,9 @@ SECTIONS {
        }
_end = .;
+
+       .comment       0 : { *(.comment) }
+       DEBUG_SYMBOLS
+
        /DISCARD/ : { *(.note.gnu.build-id) }
  }
diff --git a/plat/kvm/x86/link64.lds.S b/plat/kvm/x86/link64.lds.S
index 10951c21..a7bf4fc9 100644
--- a/plat/kvm/x86/link64.lds.S
+++ b/plat/kvm/x86/link64.lds.S
@@ -23,6 +23,8 @@
   * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   */
+#include <common-lds.h>
+
  ENTRY(_libkvmplat_entry)
  SECTIONS
  {
@@ -94,5 +96,8 @@ SECTIONS
_end = .; + .comment 0 : { *(.comment) }
+       DEBUG_SYMBOLS
+
        /DISCARD/ : { *(.note.gnu.build-id) }
  }
diff --git a/plat/xen/arm/link32.lds.S b/plat/xen/arm/link32.lds.S
index 6b038411..6d8a8069 100644
--- a/plat/xen/arm/link32.lds.S
+++ b/plat/xen/arm/link32.lds.S
@@ -24,6 +24,8 @@
   */
  /* Taken from Mini-OS */
+#include <common-lds.h>
+
  OUTPUT_ARCH(arm)
  ENTRY(_libxenplat_start)
  SECTIONS
@@ -144,5 +146,7 @@ SECTIONS
        .stab.indexstr 0 : { *(.stab.indexstr) }
        .comment 0 : { *(.comment) }
+ DEBUG_SYMBOLS
+
        /DISCARD/ : { *(.note.gnu.build-id) }
  }
diff --git a/plat/xen/x86/link64.lds.S b/plat/xen/x86/link64.lds.S
index 76b33972..02467b71 100644
--- a/plat/xen/x86/link64.lds.S
+++ b/plat/xen/x86/link64.lds.S
@@ -23,6 +23,8 @@
   */
  /* Taken from Mini-OS */
+#include <common-lds.h>
+
  OUTPUT_FORMAT("elf64-x86-64")
  OUTPUT_ARCH(i386:x86-64)
@@ -96,5 +98,9 @@ SECTIONS
                *(.exitcall.exit)
        }
        */
+
+       .comment 0 : { *(.comment) }
+       DEBUG_SYMBOLS
+
        /DISCARD/ : { *(.note.gnu.build-id) }
  }


--
Dr. Florian Schmidt
フローリアン・シュミット
Research Scientist,
Systems and Machine Learning Group
NEC Laboratories Europe
Kurfürsten-Anlage 36, D-69115 Heidelberg
Tel.     +49 (0)6221 4342-265
Fax:     +49 (0)6221 4342-155
e-mail:  florian.schmidt@xxxxxxxxx
============================================================
Registered at Amtsgericht Mannheim, Germany, HRB728558

_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.