Discussion:
[PATCH 3/3] ELF: Add testcases for PR ld/23658
H.J. Lu
2018-10-01 18:54:36 UTC
Permalink
Add testcases to verify that all SHT_NOTE sections with the same section
alignment are placed in a single PT_NOTE segment.

PR ld/23658
* testsuite/ld-elf/pr23658-1.d: New file.
* testsuite/ld-elf/pr23658-1a.s: Likewise.
* testsuite/ld-elf/pr23658-1b.s: Likewise.
* testsuite/ld-elf/pr23658-1c.s: Likewise.
* testsuite/ld-elf/pr23658-1d.s: Likewise.
* testsuite/ld-elf/pr23658-2.rd: Likewise.
* testsuite/ld-elf/pr23658-3.d: Likewise.
* testsuite/ld-elf/pr23658-3.s: Likewise.
* testsuite/ld-elf/pr23658-3.t: Likewise.
* testsuite/ld-elf/shared.exp: Run PR ld/23658 tests.
---
ld/testsuite/ld-elf/pr23658-1.d | 15 +++++++++++++++
ld/testsuite/ld-elf/pr23658-1a.s | 21 +++++++++++++++++++++
ld/testsuite/ld-elf/pr23658-1b.s | 16 ++++++++++++++++
ld/testsuite/ld-elf/pr23658-1c.s | 16 ++++++++++++++++
ld/testsuite/ld-elf/pr23658-1d.s | 16 ++++++++++++++++
ld/testsuite/ld-elf/pr23658-2.rd | 6 ++++++
ld/testsuite/ld-elf/pr23658-3.d | 8 ++++++++
ld/testsuite/ld-elf/pr23658-3.s | 4 ++++
ld/testsuite/ld-elf/pr23658-3.t | 14 ++++++++++++++
ld/testsuite/ld-elf/shared.exp | 21 +++++++++++++++++++++
10 files changed, 137 insertions(+)
create mode 100644 ld/testsuite/ld-elf/pr23658-1.d
create mode 100644 ld/testsuite/ld-elf/pr23658-1a.s
create mode 100644 ld/testsuite/ld-elf/pr23658-1b.s
create mode 100644 ld/testsuite/ld-elf/pr23658-1c.s
create mode 100644 ld/testsuite/ld-elf/pr23658-1d.s
create mode 100644 ld/testsuite/ld-elf/pr23658-2.rd
create mode 100644 ld/testsuite/ld-elf/pr23658-3.d
create mode 100644 ld/testsuite/ld-elf/pr23658-3.s
create mode 100644 ld/testsuite/ld-elf/pr23658-3.t

diff --git a/ld/testsuite/ld-elf/pr23658-1.d b/ld/testsuite/ld-elf/pr23658-1.d
new file mode 100644
index 0000000000..5f8794e7c3
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr23658-1.d
@@ -0,0 +1,15 @@
+#source: pr23658-1a.s
+#source: pr23658-1b.s
+#source: pr23658-1c.s
+#source: pr23658-1d.s
+#source: start.s
+#ld: --build-id
+#readelf: -l --wide
+# These targets don't support --build-id properly.
+#xfail: cr16-* crx-* d30v-* dlx-* fr30-* frv-* iq2000-*
+#xfail: m68hc12-* mn10200-* moxie-* mt-* msp430-* pj-*
+
+#...
+ +[0-9]+ +\.note\.4 \.note\.1 +
+ +[0-9]+ +\.note.gnu.build-id \.note\.2 .note\.3 +
+#pass
diff --git a/ld/testsuite/ld-elf/pr23658-1a.s b/ld/testsuite/ld-elf/pr23658-1a.s
new file mode 100644
index 0000000000..bc34f868fe
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr23658-1a.s
@@ -0,0 +1,21 @@
+ .text
+ .global foo
+foo:
+ .dc.a 0
+
+ .section ".note.4", "a"
+ .p2align 3
+ .long .L1 - .L0 /* name length. */
+ .long .L3 - .L1 /* data length. */
+ .long 123456 /* note type. */
+.L0:
+ .asciz "GNU" /* vendor name. */
+.L1:
+ .p2align 3
+ .long 0 /* pr_type. */
+ .long .L5 - .L4 /* pr_datasz. */
+.L4:
+ .zero 0x10
+.L5:
+ .p2align 3
+.L3:
diff --git a/ld/testsuite/ld-elf/pr23658-1b.s b/ld/testsuite/ld-elf/pr23658-1b.s
new file mode 100644
index 0000000000..3b44b42df7
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr23658-1b.s
@@ -0,0 +1,16 @@
+ .section ".note.2", "a"
+ .p2align 2
+ .long .L1 - .L0 /* name length. */
+ .long .L3 - .L1 /* data length. */
+ .long 12345 /* note type. */
+.L0:
+ .asciz "GNU" /* vendor name. */
+.L1:
+ .p2align 2
+ .long 0 /* pr_type. */
+ .long .L5 - .L4 /* pr_datasz. */
+.L4:
+ .zero 0x10
+.L5:
+ .p2align 2
+.L3:
diff --git a/ld/testsuite/ld-elf/pr23658-1c.s b/ld/testsuite/ld-elf/pr23658-1c.s
new file mode 100644
index 0000000000..fb218ce311
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr23658-1c.s
@@ -0,0 +1,16 @@
+ .section ".note.1", "a"
+ .p2align 3
+ .long .L1 - .L0 /* name length. */
+ .long .L3 - .L1 /* data length. */
+ .long 12345 /* note type. */
+.L0:
+ .asciz "GNU" /* vendor name. */
+.L1:
+ .p2align 3
+ .long 0 /* pr_type. */
+ .long .L5 - .L4 /* pr_datasz. */
+.L4:
+ .zero 0x10
+.L5:
+ .p2align 3
+.L3:
diff --git a/ld/testsuite/ld-elf/pr23658-1d.s b/ld/testsuite/ld-elf/pr23658-1d.s
new file mode 100644
index 0000000000..93fe502fb3
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr23658-1d.s
@@ -0,0 +1,16 @@
+ .section ".note.3", "a"
+ .p2align 2
+ .long .L1 - .L0 /* name length. */
+ .long .L3 - .L1 /* data length. */
+ .long 12345 /* note type. */
+.L0:
+ .asciz "GNU" /* vendor name. */
+.L1:
+ .p2align 2
+ .long 0 /* pr_type. */
+ .long .L5 - .L4 /* pr_datasz. */
+.L4:
+ .zero 0x10
+.L5:
+ .p2align 2
+.L3:
diff --git a/ld/testsuite/ld-elf/pr23658-2.rd b/ld/testsuite/ld-elf/pr23658-2.rd
new file mode 100644
index 0000000000..9f89c4b40a
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr23658-2.rd
@@ -0,0 +1,6 @@
+#...
+ +[0-9]+ +\.interp \.note.4 \.note.1 \.note.2 \.note.3.*
+#...
+ +[0-9]+ +\.note\.4 \.note\.1 +
+ +[0-9]+ +\.note\.2 .note\.3 +
+#pass
diff --git a/ld/testsuite/ld-elf/pr23658-3.d b/ld/testsuite/ld-elf/pr23658-3.d
new file mode 100644
index 0000000000..2f018aa1d2
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr23658-3.d
@@ -0,0 +1,8 @@
+#as: -mx86-used-note=yes
+#ld: -T pr23658-3.t -z noseparate-code
+#nm: -B
+#target: i?86-*-* x86_64-*-*
+
+#...
+0+4000 D __FOO
+#...
diff --git a/ld/testsuite/ld-elf/pr23658-3.s b/ld/testsuite/ld-elf/pr23658-3.s
new file mode 100644
index 0000000000..1d05efd858
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr23658-3.s
@@ -0,0 +1,4 @@
+ .data
+ .global baz
+baz:
+ .word 0
diff --git a/ld/testsuite/ld-elf/pr23658-3.t b/ld/testsuite/ld-elf/pr23658-3.t
new file mode 100644
index 0000000000..ffc3467911
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr23658-3.t
@@ -0,0 +1,14 @@
+SECTIONS
+{
+ .data 0x1000 :
+ {
+ *(.data)
+ QUAD (__FOO);
+ }
+
+ .foo 0x4000 :
+ {
+ PROVIDE (__FOO = .);
+ *(.foo)
+ }
+}
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index cdb171d0d1..c894d2196b 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -49,6 +49,12 @@ if [istarget "sparc*-*-*"] {
append AFLAGS_PIC " -K PIC"
}

+# GAS options to disable program property note.
+set AFLAGS_NOTE ""
+if { [istarget "i?86-*-*"] || [istarget "x86_64-*-*"] } {
+ append AFLAGS_NOTE "-mx86-used-note=no"
+}
+
# This target requires a non-default emulation for successful shared
# library/executable builds.
set LFLAGS ""
@@ -1474,3 +1480,18 @@ if { [istarget "i?86-*-*"]
] \
]
}
+
+run_ld_link_tests [list \
+ [list "Build pr23658.so" \
+ "-shared" "" "$AFLAGS_PIC" \
+ {pr23658-1a.s} {} "pr23658.so"] \
+ [list \
+ "Build pr23658-2" \
+ "--dynamic-linker tmpdir/pr23658.so --no-as-needed tmpdir/pr23658.so" \
+ "" \
+ $AFLAGS_NOTE \
+ { pr23658-1a.s pr23658-1b.s pr23658-1c.s pr23658-1d.s start.s } \
+ {{readelf {-lW} pr23658-2.rd}} \
+ "pr23658-2" \
+ ] \
+]
--
2.17.1
H.J. Lu
2018-10-01 18:54:35 UTC
Permalink
To support putting all adjacent SHT_NOTE sections with the same section
alignment into a single PT_NOTE segment, lang_insert_orphan must group
and sort output note sections by section alignments in both output
section list as well as output section statement list.

PR ld/23658
* ldlang.c (lang_insert_orphan): Group and sort output note
sections by section alignments.
---
ld/ldlang.c | 140 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 139 insertions(+), 1 deletion(-)

diff --git a/ld/ldlang.c b/ld/ldlang.c
index 1ac5eb1ee2..1a27787193 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -1875,6 +1875,7 @@ lang_insert_orphan (asection *s,
if (after != NULL && os->bfd_section != NULL)
{
asection *snew, *as;
+ bfd_boolean place_after = place->stmt == NULL;

snew = os->bfd_section;

@@ -1912,6 +1913,142 @@ lang_insert_orphan (asection *s,
/* Now tack it back on in the right place. */
bfd_section_list_append (link_info.output_bfd, snew);
}
+ else if ((bfd_get_flavour (link_info.output_bfd)
+ == bfd_target_elf_flavour)
+ && (bfd_get_flavour (s->owner)
+ == bfd_target_elf_flavour)
+ && ((elf_section_type (s) == SHT_NOTE
+ && (s->flags & SEC_LOAD) != 0)
+ || (elf_section_type (as) == SHT_NOTE
+ && (as->flags & SEC_LOAD) != 0)))
+ {
+ /* Make sure that output note sections are grouped and sorted
+ by alignments when inserting a note section or insert a
+ section after a note section, */
+ asection *sec;
+ /* A specific section after which the output note section
+ should be placed. */
+ asection *after_sec;
+ /* True if we need to insert the orphan section after a
+ specific section to maintain output note section order. */
+ bfd_boolean after_sec_note;
+
+ /* Group and sort output note section by alignments in
+ ascending order. */
+ after_sec = NULL;
+ if (elf_section_type (s) == SHT_NOTE
+ && (s->flags & SEC_LOAD) != 0)
+ {
+ /* Search forward for the last output note section
+ with equal or larger alignments. */
+ asection *first_note = NULL;
+
+ for (sec = as;
+ (sec != NULL
+ && !bfd_is_abs_section (sec));
+ sec = sec->next)
+ if (sec != snew
+ && elf_section_type (sec) == SHT_NOTE
+ && (sec->flags & SEC_LOAD) != 0)
+ {
+ if (!first_note)
+ first_note = sec;
+ if (sec->alignment_power >= s->alignment_power)
+ after_sec = sec;
+ }
+
+ if (after_sec)
+ after_sec_note = TRUE;
+ else
+ {
+ /* Search backward for the first output note section
+ as well as the last output note section with equal
+ or larger alignments. */
+ after_sec = NULL;
+ for (sec = as;
+ (sec != NULL
+ && !bfd_is_abs_section (sec));
+ sec = sec->prev)
+ if (sec != snew
+ && elf_section_type (sec) == SHT_NOTE
+ && (sec->flags & SEC_LOAD) != 0)
+ {
+ first_note = sec;
+ if (!after_sec
+ && sec->alignment_power >= s->alignment_power)
+ after_sec = sec;
+ }
+
+ /* If this will be the first note section, it can be
+ placed at the default location. */
+ after_sec_note = first_note != NULL;
+ if (after_sec == NULL && after_sec_note)
+ {
+ /* If all output note sections have smaller
+ alignments, place the section before all
+ output note sections. AFTER_SEC will be
+ NULL if FIRST_NOTE is the first output
+ section. */
+ after_sec = first_note->prev;
+ }
+ }
+ }
+ else
+ {
+ /* Don't place non-note sections in the middle of note
+ sections. */
+ after_sec_note = TRUE;
+ after_sec = as;
+ for (sec = as->next;
+ (sec != NULL
+ && !bfd_is_abs_section (sec));
+ sec = sec->next)
+ if (elf_section_type (sec) == SHT_NOTE
+ && (sec->flags & SEC_LOAD) != 0)
+ after_sec = sec;
+ }
+
+ if (after_sec_note)
+ {
+ if (after_sec)
+ {
+ /* Insert OS after AFTER_SEC output statement. */
+ lang_output_section_statement_type *stmt;
+ for (stmt = after;
+ stmt != NULL;
+ stmt = stmt->next)
+ if (stmt->bfd_section == after_sec)
+ {
+ place_after = TRUE;
+ after = stmt;
+ break;
+ }
+ }
+
+ if (after_sec == NULL || after_sec->next != snew)
+ {
+ /* Unlink the section. */
+ bfd_section_list_remove (link_info.output_bfd, snew);
+
+ /* Place SNEW after AFTER_SEC. If AFTER_SEC is NULL,
+ prepend SNEW. */
+ if (after_sec)
+ bfd_section_list_insert_after (link_info.output_bfd,
+ after_sec, snew);
+ else
+ bfd_section_list_prepend (link_info.output_bfd, snew);
+ }
+ }
+ else if (as != snew && as->prev != snew)
+ {
+ /* Unlink the section. */
+ bfd_section_list_remove (link_info.output_bfd, snew);
+
+ /* Now tack it back on in the right place. */
+ bfd_section_list_insert_before (link_info.output_bfd,
+ as, snew);
+ }
+ }
else if (as != snew && as->prev != snew)
{
/* Unlink the section. */
@@ -1938,7 +2075,8 @@ lang_insert_orphan (asection *s,
{
lang_output_section_statement_type *newly_added_os;

- if (place->stmt == NULL)
+ /* Place OS after AFTER if AFTER_NOTE is TRUE. */
+ if (place_after)
{
lang_statement_union_type **where = insert_os_after (after);
--
2.17.1
Nick Clifton
2018-10-03 10:31:22 UTC
Permalink
Hi H.J.
Post by H.J. Lu
PR ld/23658
* ldlang.c (lang_insert_orphan): Group and sort output note
sections by section alignments.
Approved - please apply when appropriate.

Cheers
Nick
Alan Modra
2018-10-05 10:33:24 UTC
Permalink
Post by H.J. Lu
To support putting all adjacent SHT_NOTE sections with the same section
alignment into a single PT_NOTE segment, lang_insert_orphan must group
and sort output note sections by section alignments in both output
section list as well as output section statement list.
PR ld/23658
* ldlang.c (lang_insert_orphan): Group and sort output note
sections by section alignments.
This one also breaks the spu-elf testsuite, due to changing the
placement of the .toe section. After applying the following patch to
fix the bug that caused the PT_NOTE segment to be omitted, I see two
sections being handled as orphans. First, .note.spu_name is correctly
placed after .bss, then .toe is placed after the note section
apparently due to this code:
/* Don't place non-note sections in the middle of note
sections. */
after_sec_note = TRUE;
after_sec = as;
.toe ought to be placed after .bss as it was before.


* elf32-spu.c (spu_elf_create_sections): Make .note.spu_name
SHT_NOTE.

diff --git a/bfd/elf32-spu.c b/bfd/elf32-spu.c
index c3bfbbdd03..bb3264f236 100644
--- a/bfd/elf32-spu.c
+++ b/bfd/elf32-spu.c
@@ -580,11 +580,16 @@ spu_elf_create_sections (struct bfd_link_info *info)
flagword flags;

ibfd = info->input_bfds;
+ /* This should really be SEC_LINKER_CREATED, but then we'd need
+ to write out the section ourselves. */
flags = SEC_LOAD | SEC_READONLY | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
s = bfd_make_section_anyway_with_flags (ibfd, SPU_PTNOTE_SPUNAME, flags);
if (s == NULL
|| !bfd_set_section_alignment (ibfd, s, 4))
return FALSE;
+ /* Because we didn't set SEC_LINKER_CREATED we need to set the
+ proper section type. */
+ elf_section_type (s) = SHT_NOTE;

name_len = strlen (bfd_get_filename (info->output_bfd)) + 1;
size = 12 + ((sizeof (SPU_PLUGIN_NAME) + 3) & -4);
--
Alan Modra
Australia Development Lab, IBM
H.J. Lu
2018-10-01 18:54:34 UTC
Permalink
Alignments of SHT_NOTE sections can be 8 bytes for 64-bit ELF files. We
should put all adjacent SHT_NOTE sections with the same section alignment
into a single PT_NOTE segment even when the section alignment != 4 bytes.

PR ld/23658
* elf.c (get_program_header_size): Put all adjacent SHT_NOTE
sections with the same section alignment into a single PT_NOTE
segment.
(_bfd_elf_map_sections_to_segments): Likewise.
---
bfd/elf.c | 50 +++++++++++++++++++++++++-------------------------
1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/bfd/elf.c b/bfd/elf.c
index 5320ae2237..52ffb0ccab 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -4373,21 +4373,20 @@ get_program_header_size (bfd *abfd, struct bfd_link_info *info)
if ((s->flags & SEC_LOAD) != 0
&& CONST_STRNEQ (s->name, ".note"))
{
+ unsigned int alignment_power;
/* We need a PT_NOTE segment. */
++segs;
- /* Try to create just one PT_NOTE segment
- for all adjacent loadable .note* sections.
- gABI requires that within a PT_NOTE segment
- (and also inside of each SHT_NOTE section)
- each note is padded to a multiple of 4 size,
- so we check whether the sections are correctly
- aligned. */
- if (s->alignment_power == 2)
- while (s->next != NULL
- && s->next->alignment_power == 2
- && (s->next->flags & SEC_LOAD) != 0
- && CONST_STRNEQ (s->next->name, ".note"))
- s = s->next;
+ /* Try to create just one PT_NOTE segment for all adjacent
+ loadable .note* sections. gABI requires that within a
+ PT_NOTE segment (and also inside of each SHT_NOTE section)
+ each note should have the same alignment. So we check
+ whether the sections are correctly aligned. */
+ alignment_power = s->alignment_power;
+ while (s->next != NULL
+ && s->next->alignment_power == alignment_power
+ && (s->next->flags & SEC_LOAD) != 0
+ && CONST_STRNEQ (s->next->name, ".note"))
+ s = s->next;
}
}

@@ -4897,21 +4896,22 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info)
&& CONST_STRNEQ (s->name, ".note"))
{
asection *s2;
+ unsigned int alignment_power = s->alignment_power;

count = 1;
amt = sizeof (struct elf_segment_map);
- if (s->alignment_power == 2)
- for (s2 = s; s2->next != NULL; s2 = s2->next)
- {
- if (s2->next->alignment_power == 2
- && (s2->next->flags & SEC_LOAD) != 0
- && CONST_STRNEQ (s2->next->name, ".note")
- && align_power (s2->lma + s2->size, 2)
- == s2->next->lma)
- count++;
- else
- break;
- }
+ for (s2 = s; s2->next != NULL; s2 = s2->next)
+ {
+ if (s2->next->alignment_power == alignment_power
+ && (s2->next->flags & SEC_LOAD) != 0
+ && CONST_STRNEQ (s2->next->name, ".note")
+ && align_power (s2->lma + s2->size,
+ alignment_power)
+ == s2->next->lma)
+ count++;
+ else
+ break;
+ }
amt += (count - 1) * sizeof (asection *);
m = (struct elf_segment_map *) bfd_zalloc (abfd, amt);
if (m == NULL)
--
2.17.1
Nick Clifton
2018-10-03 10:30:08 UTC
Permalink
Hi H.J.
Post by H.J. Lu
+ while (s->next != NULL
+ && s->next->alignment_power == alignment_power
+ && (s->next->flags & SEC_LOAD) != 0
+ && CONST_STRNEQ (s->next->name, ".note"))
+ s = s->next;
I did not think that note sections were required to have a ".note"
prefix to their name. So wouldn't it be better to check for a SHF_NOTE
flag instead ? (Assuming that the section is in an ELF format bfd, of
course).

I appreciate that the code that you are patching also used the CONST_STRNEQ
check, but I am thinking that now would be a good time to fix this bug
as well. If the section is not in an ELF format file, you could always
fall back on checking for the .note prefix.

Cheers
Nick
H.J. Lu
2018-10-03 12:55:19 UTC
Permalink
Post by Nick Clifton
Hi H.J.
+ while (s->next != NULL
+ && s->next->alignment_power == alignment_power
+ && (s->next->flags & SEC_LOAD) != 0
+ && CONST_STRNEQ (s->next->name, ".note"))
+ s = s->next;
I did not think that note sections were required to have a ".note"
prefix to their name. So wouldn't it be better to check for a SHF_NOTE
flag instead ? (Assuming that the section is in an ELF format bfd, of
course).
I appreciate that the code that you are patching also used the CONST_STRNEQ
check, but I am thinking that now would be a good time to fix this bug
as well. If the section is not in an ELF format file, you could always
fall back on checking for the .note prefix.
get_program_header_size and _bfd_elf_map_sections_to_segments are only
used on ELF files. This updated patch checks SHT_NOTE section type instead.
OK for master?

Thanks.
--
H.J.
Nick Clifton
2018-10-03 14:30:36 UTC
Permalink
Hi H.J.
Post by H.J. Lu
Post by Nick Clifton
I did not think that note sections were required to have a ".note"
prefix to their name. So wouldn't it be better to check for a SHF_NOTE
flag instead ? (Assuming that the section is in an ELF format bfd, of
course).
get_program_header_size and _bfd_elf_map_sections_to_segments are only
used on ELF files.
I suspected as much, but I was being paranoid. And also too lazy to check
the code for myself...
Post by H.J. Lu
This updated patch checks SHT_NOTE section type instead.
OK for master?
Approved -please apply.

Cheers
Nick
Alan Modra
2018-10-05 04:24:00 UTC
Permalink
Post by H.J. Lu
PR ld/23658
* elf.c (get_program_header_size): Put all adjacent SHT_NOTE
sections with the same section alignment into a single PT_NOTE
segment. Check SHT_NOTE section type instead of section name.
(_bfd_elf_map_sections_to_segments): Likewise.
This patch caused a PT_NOTE header to be dropped in the following tests:
spu-elf +FAIL: ld-spu/ovl
spu-elf +FAIL: ld-spu/ovl2
--
Alan Modra
Australia Development Lab, IBM
Nick Clifton
2018-10-03 10:34:25 UTC
Permalink
Hi H.J.
Post by H.J. Lu
Add testcases to verify that all SHT_NOTE sections with the same section
alignment are placed in a single PT_NOTE segment.
+#ld: --build-id
+#readelf: -l --wide
+# These targets don't support --build-id properly.
+#xfail: cr16-* crx-* d30v-* dlx-* fr30-* frv-* iq2000-*
+#xfail: m68hc12-* mn10200-* moxie-* mt-* msp430-* pj-*
Is the build-id note necessary ? You could check note segment assignment
without it...

Cheers
Nick
H.J. Lu
2018-10-03 12:36:35 UTC
Permalink
Post by Nick Clifton
Hi H.J.
Post by H.J. Lu
Add testcases to verify that all SHT_NOTE sections with the same section
alignment are placed in a single PT_NOTE segment.
+#ld: --build-id
+#readelf: -l --wide
+# These targets don't support --build-id properly.
+#xfail: cr16-* crx-* d30v-* dlx-* fr30-* frv-* iq2000-*
+#xfail: m68hc12-* mn10200-* moxie-* mt-* msp430-* pj-*
Is the build-id note necessary ? You could check note segment assignment
without it...
This test checks if the .note.gnu.build-id section is properly handled.
--
H.J.
Nick Clifton
2018-10-03 14:29:08 UTC
Permalink
Hi H.J.
Post by H.J. Lu
Post by Nick Clifton
Is the build-id note necessary ? You could check note segment assignment
without it...
This test checks if the .note.gnu.build-id section is properly handled.
But you could easily have two tests. One which checks that .note.gnu.build-id
is handled properly, but which will not run on targets which do not support the
generation of build-ids. Then you could have a second test, which would run
for all (ELF) targets, which does not use --build-id, but which does still check
that similarly aligned notes are combined and placed into properly aligned segments.

Cheers
Nick
H.J. Lu
2018-10-03 16:26:44 UTC
Permalink
Post by Nick Clifton
Hi H.J.
Post by H.J. Lu
Post by Nick Clifton
Is the build-id note necessary ? You could check note segment assignment
without it...
This test checks if the .note.gnu.build-id section is properly handled.
But you could easily have two tests. One which checks that .note.gnu.build-id
is handled properly, but which will not run on targets which do not support the
generation of build-ids. Then you could have a second test, which would run
for all (ELF) targets, which does not use --build-id, but which does still check
that similarly aligned notes are combined and placed into properly aligned segments.
The reason why these targets are skipped is that they use generic
linker, not ELF
linker. This test is irrelevant for these targets.
--
H.J.
H.J. Lu
2018-10-03 20:37:50 UTC
Permalink
Post by H.J. Lu
Post by Nick Clifton
Hi H.J.
Post by H.J. Lu
Post by Nick Clifton
Is the build-id note necessary ? You could check note segment assignment
without it...
This test checks if the .note.gnu.build-id section is properly handled.
But you could easily have two tests. One which checks that .note.gnu.build-id
is handled properly, but which will not run on targets which do not support the
generation of build-ids. Then you could have a second test, which would run
for all (ELF) targets, which does not use --build-id, but which does still check
that similarly aligned notes are combined and placed into properly aligned segments.
The reason why these targets are skipped is that they use generic
linker, not ELF
linker. This test is irrelevant for these targets.
Since generic linker targets don't place SHT_NOTE sections as orphan, SHT_NOTE
sections aren't grouped nor sorted. I am checking in this updated patch.
--
H.J.
Loading...