diff options
author | Mark Wielaard <mark@klomp.org> | 2017-07-20 22:34:29 +0200 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2017-07-24 12:20:01 +0200 |
commit | 55cb7dfa7e9afb3660b21e51434641c7287baf11 (patch) | |
tree | 9fc5ed4d912e682084cf97dca3b655be0905b6c0 /backends | |
parent | 1609679b1ef3611c71a08900c2f6b94bb97d454d (diff) |
strip: Deal with ARM data marker symbols pointing to debug sections.
ARM data marker symbols "$d" indicate the start of a sequence of data
items in a section. For data only sections no data marker symbol is
necessary, but may be put pointing to the start of the section.
binutils however has a bug which places a data marker symbol somewhere
inside the section (at least for .debug_frame).
https://sourceware.org/bugzilla/show_bug.cgi?id=21809
When strip finds a symbol pointing to a debug section that would be
put into the .debug file then it will copy over the whole symbol table.
This isn't necessary because the symbol is redundant.
Add an ebl hook to recognize data marker symbols with implementations
for arm and aarch64. Use it in strip to strip such symbols from the
symbol table if they point to a debug section.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'backends')
-rw-r--r-- | backends/ChangeLog | 7 | ||||
-rw-r--r-- | backends/aarch64_init.c | 3 | ||||
-rw-r--r-- | backends/aarch64_symbol.c | 14 | ||||
-rw-r--r-- | backends/arm_init.c | 3 | ||||
-rw-r--r-- | backends/arm_symbol.c | 15 |
5 files changed, 38 insertions, 4 deletions
diff --git a/backends/ChangeLog b/backends/ChangeLog index eb7e25f1..88b9764a 100644 --- a/backends/ChangeLog +++ b/backends/ChangeLog @@ -1,3 +1,10 @@ +2017-08-20 Mark Wielaard <mark@klomp.org> + + * aarch64_init.c (aarch64_init): Hook data_marker_symbol. + * aarch64_symbol.c (aarch64_data_marker_symbol): New function. + * arm_init.c (arm_init): Hook data_marker_symbol. + * arm_symbol.c (aarch64_data_marker_symbol): New function. + 2017-07-18 Mark Wielaard <mark@klomp.org> * Makefile.am (cpu_bpf): Always define. diff --git a/backends/aarch64_init.c b/backends/aarch64_init.c index 08664943..fad923fa 100644 --- a/backends/aarch64_init.c +++ b/backends/aarch64_init.c @@ -1,5 +1,5 @@ /* Initialization of AArch64 specific backend library. - Copyright (C) 2013 Red Hat, Inc. + Copyright (C) 2013, 2017 Red Hat, Inc. This file is part of elfutils. This file is free software; you can redistribute it and/or modify @@ -56,6 +56,7 @@ aarch64_init (Elf *elf __attribute__ ((unused)), HOOK (eh, reloc_simple_type); HOOK (eh, return_value_location); HOOK (eh, check_special_symbol); + HOOK (eh, data_marker_symbol); HOOK (eh, abi_cfi); /* X0-X30 (31 regs) + SP + 1 Reserved + ELR, 30 Reserved regs (34-43) diff --git a/backends/aarch64_symbol.c b/backends/aarch64_symbol.c index 76999e4b..da3382e9 100644 --- a/backends/aarch64_symbol.c +++ b/backends/aarch64_symbol.c @@ -1,5 +1,5 @@ /* AArch64 specific symbolic name handling. - Copyright (C) 2013, 2015 Red Hat, Inc. + Copyright (C) 2013, 2015, 2017 Red Hat, Inc. This file is part of elfutils. This file is free software; you can redistribute it and/or modify @@ -90,3 +90,15 @@ aarch64_check_special_symbol (Elf *elf, GElf_Ehdr *ehdr, const GElf_Sym *sym, return false; } + +/* A data mapping symbol is a symbol with "$d" name or "$d.<any...>" name, + STT_NOTYPE, STB_LOCAL and st_size of zero. The indicate the stat of a + sequence of data items. */ +bool +aarch64_data_marker_symbol (const GElf_Sym *sym, const char *sname) +{ + return (sym != NULL && sname != NULL + && sym->st_size == 0 && GELF_ST_BIND (sym->st_info) == STB_LOCAL + && GELF_ST_TYPE (sym->st_info) == STT_NOTYPE + && (strcmp (sname, "$d") == 0 || strncmp (sname, "$d.", 3) == 0)); +} diff --git a/backends/arm_init.c b/backends/arm_init.c index caadac65..f2b1b11e 100644 --- a/backends/arm_init.c +++ b/backends/arm_init.c @@ -1,5 +1,5 @@ /* Initialization of Arm specific backend library. - Copyright (C) 2002, 2005, 2009, 2013, 2014, 2015 Red Hat, Inc. + Copyright (C) 2002, 2005, 2009, 2013, 2014, 2015, 2017 Red Hat, Inc. This file is part of elfutils. Written by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -64,6 +64,7 @@ arm_init (Elf *elf __attribute__ ((unused)), HOOK (eh, abi_cfi); HOOK (eh, check_reloc_target_type); HOOK (eh, symbol_type_name); + HOOK (eh, data_marker_symbol); /* We only unwind the core integer registers. */ eh->frame_nregs = 16; diff --git a/backends/arm_symbol.c b/backends/arm_symbol.c index da4a50a7..3edda724 100644 --- a/backends/arm_symbol.c +++ b/backends/arm_symbol.c @@ -1,5 +1,5 @@ /* Arm specific symbolic name handling. - Copyright (C) 2002-2009, 2014, 2015 Red Hat, Inc. + Copyright (C) 2002-2009, 2014, 2015, 2017 Red Hat, Inc. This file is part of elfutils. This file is free software; you can redistribute it and/or modify @@ -32,6 +32,7 @@ #include <elf.h> #include <stddef.h> +#include <string.h> #define BACKEND arm_ #include "libebl_CPU.h" @@ -142,3 +143,15 @@ arm_symbol_type_name (int type, } return NULL; } + +/* A data mapping symbol is a symbol with "$d" name or "$d.<any...>" name, + * STT_NOTYPE, STB_LOCAL and st_size of zero. The indicate the stat of a + * sequence of data items. */ +bool +arm_data_marker_symbol (const GElf_Sym *sym, const char *sname) +{ + return (sym != NULL && sname != NULL + && sym->st_size == 0 && GELF_ST_BIND (sym->st_info) == STB_LOCAL + && GELF_ST_TYPE (sym->st_info) == STT_NOTYPE + && (strcmp (sname, "$d") == 0 || strncmp (sname, "$d.", 3) == 0)); +} |