From: "H. J. Lu" <hjl@lucon.org>
To: Ashutosh Yeole <ashutoshy@KPITCummins.com>,
binutils@sourceware.org, Ben Elliston <bje@au1.ibm.com>
Subject: Re: NOLOAD problem with binutils 2.16.92
Date: Tue, 01 Aug 2006 17:43:00 -0000 [thread overview]
Message-ID: <20060801174347.GA11068@lucon.org> (raw)
In-Reply-To: <20060731234540.GA13447@bubble.grove.modra.org>
On Tue, Aug 01, 2006 at 09:15:40AM +0930, Alan Modra wrote:
> On Mon, Jul 31, 2006 at 01:03:18PM -0700, H. J. Lu wrote:
> > 2006-07-31 H.J. Lu <hongjiu.lu@intel.com>
> >
> > * ldlang.c (init_os): Add flags. Replace bfd_make_section with
> > bfd_make_section_with_flags.
> > (exp_init_os): Updated.
> > (lang_add_section): Call init_os with flags.
> > (map_input_to_output_sections): Likewise.
>
> The idea looks OK to me.
>
I am checking this patch with a testcase.
H.J.
---
ld/
2006-08-01 H.J. Lu <hongjiu.lu@intel.com>
* ldlang.c (init_os): Add flags. Replace bfd_make_section with
bfd_make_section_with_flags.
(exp_init_os): Updated.
(lang_add_section): Call init_os with flags.
(map_input_to_output_sections): Likewise.
ld/testsuite/
2006-08-01 H.J. Lu <hongjiu.lu@intel.com>
* ld-elf/noload-1.d: New.
* ld-elf/noload-1.s: Likewise.
* ld-elf/noload-1.t: Likewise.
--- ld/ldlang.c.noload 2006-07-28 13:58:01.000000000 -0700
+++ ld/ldlang.c 2006-08-01 10:38:23.000000000 -0700
@@ -1859,7 +1859,8 @@ sort_def_symbol (hash_entry, info)
/* Initialize an output section. */
static void
-init_os (lang_output_section_statement_type *s, asection *isec)
+init_os (lang_output_section_statement_type *s, asection *isec,
+ flagword flags)
{
if (s->bfd_section != NULL)
return;
@@ -1869,7 +1870,8 @@ init_os (lang_output_section_statement_t
s->bfd_section = bfd_get_section_by_name (output_bfd, s->name);
if (s->bfd_section == NULL)
- s->bfd_section = bfd_make_section (output_bfd, s->name);
+ s->bfd_section = bfd_make_section_with_flags (output_bfd, s->name,
+ flags);
if (s->bfd_section == NULL)
{
einfo (_("%P%F: output format %s cannot represent section called %s\n"),
@@ -1947,7 +1949,7 @@ exp_init_os (etree_type *exp)
os = lang_output_section_find (exp->name.name);
if (os != NULL && os->bfd_section == NULL)
- init_os (os, NULL);
+ init_os (os, NULL, 0);
}
}
break;
@@ -2022,8 +2024,32 @@ lang_add_section (lang_statement_list_ty
lang_input_section_type *new;
flagword flags;
+ flags = section->flags;
+
+ /* We don't copy the SEC_NEVER_LOAD flag from an input section
+ to an output section, because we want to be able to include a
+ SEC_NEVER_LOAD section in the middle of an otherwise loaded
+ section (I don't know why we want to do this, but we do).
+ build_link_order in ldwrite.c handles this case by turning
+ the embedded SEC_NEVER_LOAD section into a fill. */
+
+ flags &= ~ SEC_NEVER_LOAD;
+
+ switch (output->sectype)
+ {
+ case normal_section:
+ break;
+ case noalloc_section:
+ flags &= ~SEC_ALLOC;
+ break;
+ case noload_section:
+ flags &= ~SEC_LOAD;
+ flags |= SEC_NEVER_LOAD;
+ break;
+ }
+
if (output->bfd_section == NULL)
- init_os (output, section);
+ init_os (output, section, flags);
first = ! output->bfd_section->linker_has_input;
output->bfd_section->linker_has_input = 1;
@@ -2047,17 +2073,6 @@ lang_add_section (lang_statement_list_ty
new->section = section;
section->output_section = output->bfd_section;
- flags = section->flags;
-
- /* We don't copy the SEC_NEVER_LOAD flag from an input section
- to an output section, because we want to be able to include a
- SEC_NEVER_LOAD section in the middle of an otherwise loaded
- section (I don't know why we want to do this, but we do).
- build_link_order in ldwrite.c handles this case by turning
- the embedded SEC_NEVER_LOAD section into a fill. */
-
- flags &= ~ SEC_NEVER_LOAD;
-
/* If final link, don't copy the SEC_LINK_ONCE flags, they've
already been processed. One reason to do this is that on pe
format targets, .text$foo sections go into .text and it's odd
@@ -2094,19 +2109,6 @@ lang_add_section (lang_statement_list_ty
if ((section->flags & SEC_READONLY) == 0)
output->bfd_section->flags &= ~SEC_READONLY;
- switch (output->sectype)
- {
- case normal_section:
- break;
- case noalloc_section:
- output->bfd_section->flags &= ~SEC_ALLOC;
- break;
- case noload_section:
- output->bfd_section->flags &= ~SEC_LOAD;
- output->bfd_section->flags |= SEC_NEVER_LOAD;
- break;
- }
-
/* Copy over SEC_SMALL_DATA. */
if (section->flags & SEC_SMALL_DATA)
output->bfd_section->flags |= SEC_SMALL_DATA;
@@ -3202,6 +3204,8 @@ map_input_to_output_sections
(lang_statement_union_type *s, const char *target,
lang_output_section_statement_type *os)
{
+ flagword flags;
+
for (; s != NULL; s = s->header.next)
{
switch (s->header.type)
@@ -3251,13 +3255,15 @@ map_input_to_output_sections
/* Make sure that any sections mentioned in the expression
are initialized. */
exp_init_os (s->data_statement.exp);
- if (os != NULL && os->bfd_section == NULL)
- init_os (os, NULL);
+ flags = SEC_HAS_CONTENTS;
/* The output section gets contents, and then we inspect for
any flags set in the input script which override any ALLOC. */
- os->bfd_section->flags |= SEC_HAS_CONTENTS;
if (!(os->flags & SEC_NEVER_LOAD))
- os->bfd_section->flags |= SEC_ALLOC | SEC_LOAD;
+ flags |= SEC_ALLOC | SEC_LOAD;
+ if (os->bfd_section == NULL)
+ init_os (os, NULL, flags);
+ else
+ os->bfd_section->flags |= flags;
break;
case lang_input_section_enum:
break;
@@ -3267,11 +3273,11 @@ map_input_to_output_sections
case lang_padding_statement_enum:
case lang_input_statement_enum:
if (os != NULL && os->bfd_section == NULL)
- init_os (os, NULL);
+ init_os (os, NULL, 0);
break;
case lang_assignment_statement_enum:
if (os != NULL && os->bfd_section == NULL)
- init_os (os, NULL);
+ init_os (os, NULL, 0);
/* Make sure that any sections mentioned in the assignment
are initialized. */
@@ -3299,7 +3305,7 @@ map_input_to_output_sections
(s->address_statement.section_name));
if (aos->bfd_section == NULL)
- init_os (aos, NULL);
+ init_os (aos, NULL, 0);
aos->addr_tree = s->address_statement.address;
}
break;
--- ld/testsuite/ld-elf/noload-1.d.noload 2006-08-01 10:34:41.000000000 -0700
+++ ld/testsuite/ld-elf/noload-1.d 2006-08-01 10:34:15.000000000 -0700
@@ -0,0 +1,7 @@
+#source: noload-1.s
+#ld: -T noload-1.t
+#readelf: -S --wide
+
+#...
+ \[[ 0-9]+\] TEST[ \t]+NOBITS[ \t0-9a-f]+WA.*
+#pass
--- ld/testsuite/ld-elf/noload-1.s.noload 2006-08-01 10:34:41.000000000 -0700
+++ ld/testsuite/ld-elf/noload-1.s 2006-08-01 10:28:24.000000000 -0700
@@ -0,0 +1,2 @@
+ .section TEST,"aw",%progbits
+ .byte 0
--- ld/testsuite/ld-elf/noload-1.t.noload 2006-08-01 10:34:41.000000000 -0700
+++ ld/testsuite/ld-elf/noload-1.t 2006-08-01 10:30:04.000000000 -0700
@@ -0,0 +1,8 @@
+SECTIONS
+{
+ TEST (NOLOAD) :
+ {
+ *(TEST)
+ }
+ /DISCARD/ : { *(.*) }
+}
next prev parent reply other threads:[~2006-08-01 17:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-26 10:01 Ashutosh Yeole
2006-07-26 20:11 ` Ramana Radhakrishnan
2006-07-28 7:32 ` Ben Elliston
2006-07-31 13:21 ` Ashutosh Yeole
2006-07-31 14:54 ` H. J. Lu
2006-07-31 20:03 ` H. J. Lu
2006-07-31 23:45 ` Alan Modra
2006-08-01 17:43 ` H. J. Lu [this message]
-- strict thread matches above, loose matches on Subject: below --
2006-07-18 12:54 Ashutosh Yeole
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060801174347.GA11068@lucon.org \
--to=hjl@lucon.org \
--cc=ashutoshy@KPITCummins.com \
--cc=binutils@sourceware.org \
--cc=bje@au1.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).