Michael Matz 2019-11-18 17:53:50 +00:00 committed by Git OBS Bridge
parent be501ec5b6
commit d6d76202e8

View File

@ -5,23 +5,17 @@ input files contains a section named .ulp.track.
Index: bfd/elflink.c
===================================================================
--- bfd/elflink.c.orig 2019-09-09 15:19:43.000000000 +0200
+++ bfd/elflink.c 2019-11-18 18:02:54.000000000 +0100
@@ -22,6 +22,7 @@
#include "bfd.h"
#include "bfdlink.h"
#include "libbfd.h"
+#include "ulp.h"
#define ARCH_SIZE 0
#include "elf-bfd.h"
#include "safe-ctype.h"
@@ -7070,6 +7071,11 @@ bfd_elf_size_dynamic_sections (bfd *outp
+++ bfd/elflink.c 2019-11-18 18:50:53.000000000 +0100
@@ -7070,6 +7070,13 @@ bfd_elf_size_dynamic_sections (bfd *outp
s = bfd_get_linker_section (dynobj, ".gnu.version");
s->flags |= SEC_EXCLUDE;
}
+
+ if (bfd_is_ulp_enabled(output_bfd))
+ if (bed->elf_backend_is_ulp_enabled != NULL
+ && bed->elf_backend_setup_ulp != NULL
+ && (*bed->elf_backend_is_ulp_enabled) (output_bfd))
+ {
+ bfd_setup_ulp(info);
+ (*bed->elf_backend_setup_ulp)(info);
+ }
}
return TRUE;
@ -29,23 +23,24 @@ Index: bfd/elflink.c
Index: bfd/elfxx-x86.c
===================================================================
--- bfd/elfxx-x86.c.orig 2019-09-09 15:19:43.000000000 +0200
+++ bfd/elfxx-x86.c 2019-11-18 18:02:54.000000000 +0100
@@ -23,6 +23,7 @@
#include "objalloc.h"
#include "elf/i386.h"
#include "elf/x86-64.h"
+#include "ulp.h"
+++ bfd/elfxx-x86.c 2019-11-18 18:51:01.000000000 +0100
@@ -31,6 +31,8 @@
#define ELF64_DYNAMIC_INTERPRETER "/lib/ld64.so.1"
#define ELFX32_DYNAMIC_INTERPRETER "/lib/ldx32.so.1"
/* The name of the dynamic interpreter. This is put in the .interp
section. */
@@ -952,6 +953,64 @@ _bfd_x86_elf_link_check_relocs (bfd *abf
+#define ULP_ENTRY_LEN 16
+
bfd_boolean
_bfd_x86_elf_mkobject (bfd *abfd)
{
@@ -952,6 +954,64 @@ _bfd_x86_elf_link_check_relocs (bfd *abf
return _bfd_elf_link_check_relocs (abfd, info);
}
+/* Check if input bfds are ulp-enabled by containing .ulp.track section */
+
+bfd_boolean
+bfd_x86_elf_is_ulp_enabled (struct bfd *input_bfd)
+_bfd_x86_elf_is_ulp_enabled (struct bfd *input_bfd)
+{
+ while (input_bfd != NULL)
+ for (; input_bfd != NULL; input_bfd = input_bfd->link.next)
@ -73,7 +68,7 @@ Index: bfd/elfxx-x86.c
+/* Fill the user-space live patching section */
+
+bfd_boolean
+bfd_x86_elf_setup_ulp (struct bfd_link_info *info)
+_bfd_x86_elf_setup_ulp (struct bfd_link_info *info)
+{
+ struct elf_x86_link_hash_table *htab;
+ asection *ulp;
@ -103,7 +98,7 @@ Index: bfd/elfxx-x86.c
/* Set the sizes of the dynamic sections. */
bfd_boolean
@@ -2935,7 +2994,26 @@ error_alignment:
@@ -2935,7 +2995,26 @@ error_alignment:
htab->plt_second = sec;
}
@ -134,7 +129,7 @@ Index: bfd/elfxx-x86.c
Index: bfd/elfxx-x86.h
===================================================================
--- bfd/elfxx-x86.h.orig 2019-09-09 15:19:43.000000000 +0200
+++ bfd/elfxx-x86.h 2019-11-18 18:02:54.000000000 +0100
+++ bfd/elfxx-x86.h 2019-11-18 18:47:32.000000000 +0100
@@ -447,6 +447,7 @@ struct elf_x86_link_hash_table
asection *plt_second_eh_frame;
asection *plt_got;
@ -143,20 +138,67 @@ Index: bfd/elfxx-x86.h
/* Parameters describing PLT generation, lazy or non-lazy. */
struct elf_x86_plt_layout plt;
Index: bfd/ulp.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ bfd/ulp.h 2019-11-18 18:02:54.000000000 +0100
@@ -0,0 +1,12 @@
+extern bfd_boolean bfd_x86_elf_is_ulp_enabled
@@ -708,6 +709,12 @@ extern void _bfd_x86_elf_link_fixup_ifun
(struct bfd_link_info *, struct elf_x86_link_hash_table *,
struct elf_link_hash_entry *, Elf_Internal_Sym *sym);
+extern bfd_boolean _bfd_x86_elf_is_ulp_enabled
+ (struct bfd *);
+
+extern bfd_boolean bfd_x86_elf_setup_ulp
+extern bfd_boolean _bfd_x86_elf_setup_ulp
+ (struct bfd_link_info *);
+
+#define bfd_is_ulp_enabled bfd_x86_elf_is_ulp_enabled
#define bfd_elf64_mkobject \
_bfd_x86_elf_mkobject
#define bfd_elf32_mkobject \
@@ -745,3 +752,7 @@ extern void _bfd_x86_elf_link_fixup_ifun
_bfd_x86_elf_merge_gnu_properties
#define elf_backend_fixup_gnu_properties \
_bfd_x86_elf_link_fixup_gnu_properties
+#define elf_backend_is_ulp_enabled \
+ _bfd_x86_elf_is_ulp_enabled
+#define elf_backend_setup_ulp \
+ _bfd_x86_elf_setup_ulp
Index: bfd/elf-bfd.h
===================================================================
--- bfd/elf-bfd.h.orig 2019-09-09 15:19:43.000000000 +0200
+++ bfd/elf-bfd.h 2019-11-18 18:47:43.000000000 +0100
@@ -1423,6 +1423,10 @@ struct elf_backend_data
(const bfd *ibfd, bfd *obfd, const Elf_Internal_Shdr *isection,
Elf_Internal_Shdr *osection);
+ bfd_boolean (*elf_backend_is_ulp_enabled) (bfd *abfd);
+
+#define bfd_setup_ulp bfd_x86_elf_setup_ulp
+ bfd_boolean (*elf_backend_setup_ulp) (struct bfd_link_info *);
+
+#define ULP_ENTRY_LEN 16
/* Used to handle bad SHF_LINK_ORDER input. */
void (*link_order_error_handler) (const char *, ...);
Index: bfd/elfxx-target.h
===================================================================
--- bfd/elfxx-target.h.orig 2019-09-09 15:19:43.000000000 +0200
+++ bfd/elfxx-target.h 2019-11-18 18:50:34.000000000 +0100
@@ -754,6 +754,14 @@
#define elf_backend_copy_special_section_fields NULL
#endif
+#ifndef elf_backend_is_ulp_enabled
+#define elf_backend_is_ulp_enabled NULL
+#endif
+
+#ifndef elf_backend_setup_ulp
+#define elf_backend_setup_ulp NULL
+#endif
+
#ifndef elf_backend_compact_eh_encoding
#define elf_backend_compact_eh_encoding NULL
#endif
@@ -867,6 +875,8 @@ static struct elf_backend_data elfNN_bed
elf_backend_maybe_function_sym,
elf_backend_get_reloc_section,
elf_backend_copy_special_section_fields,
+ elf_backend_is_ulp_enabled,
+ elf_backend_setup_ulp,
elf_backend_link_order_error_handler,
elf_backend_relplt_name,
ELF_MACHINE_ALT1,