This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: x86-64 large data sections updated
On Wed, Jun 15, 2005 at 01:54:58PM +0200, Jan Hubicka wrote:
> > On Wed, Jun 15, 2005 at 12:13:15AM +0200, Jan Hubicka wrote:
> > > Index: bfd/elf64-x86-64.c
> > > ===================================================================
> > > RCS file: /cvs/src/src/bfd/elf64-x86-64.c,v
> > > retrieving revision 1.95
> > > diff -c -3 -p -r1.95 elf64-x86-64.c
> > > *** bfd/elf64-x86-64.c 17 May 2005 16:43:02 -0000 1.95
> > > --- bfd/elf64-x86-64.c 14 Jun 2005 21:50:20 -0000
> > > *************** elf64_x86_64_check_relocs (bfd *abfd, st
> > > *** 975,980 ****
> > > --- 991,1028 ----
> > > return TRUE;
> > > }
> > >
> > > + /* Hook called by the linker routine which adds symbols from an object
> > > + file. We use it to put .comm items in .lbss, and not .bss. */
> > > +
> > > + static bfd_boolean
> > > + elf64_x86_64_add_symbol_hook (bfd *abfd, struct bfd_link_info *info ATTRIBUTE_UNUSED,
> > > + Elf_Internal_Sym *sym, const char **namep ATTRIBUTE_UNUSED,
> > > + flagword *flagsp ATTRIBUTE_UNUSED,
> > > + asection **secp, bfd_vma *valp)
> > > + {
> > > + if (sym->st_shndx == SHN_X86_64_LCOMMON)
> > > + {
> > > +
> > > + asection *lcomm = bfd_get_section_by_name (abfd, ".lbss");
> > > +
> > > + if (lcomm == NULL)
> > > + {
> > > + lcomm = bfd_make_section (abfd, ".lbss");
> > > + if (lcomm == NULL
> > > + || !bfd_set_section_flags (abfd, lcomm, (SEC_ALLOC
> > > + | SEC_IS_COMMON
> > > + | SEC_LINKER_CREATED)))
> > > + return FALSE;
> > > + }
> > > +
> > > + *secp = lcomm;
> > > + *valp = sym->st_size;
> > > + }
> > > +
> > > + return TRUE;
> > > + }
> > > +
> > > +
> >
> > There are 2 problems:
> >
> > 1. You can't use .lbss section index in symbol table for
> > SHN_X86_64_LCOMMON. They are different. I don't think you can
> > set SEC_IS_COMMON for .lbss.
> > 2. I don't think like creating a real section for common symbol. I know
> > MIPS does it this way. But it doesn't make it right. There is
> > SHN_X86_64_LCOMMON. It should be used in symbol table.
>
> I think it is safe to drop this function (I confused it with the other
> when responding to Richard's mail.
This function may be needed to map SHN_X86_64_LCOMMON into some
section for input file. But I need to take a second look.
> >
> >
> > > /* Return the section that should be marked against GC for a given
> > > relocation. */
> > >
> > > *************** elf64_x86_64_section_from_shdr (bfd *abf
> > > *** 2839,2844 ****
> > > --- 2912,2985 ----
> > > return TRUE;
> > > }
> > >
> > > + /* Given a BFD section, try to locate the corresponding ELF section
> > > + index. This is used by both the 32-bit and the 64-bit ABI.
> > > + Actually, it's not clear to me that the 64-bit ABI supports these,
> > > + but for non-PIC objects we will certainly want support for at least
> > > + the .scommon section. */
> > > +
> > > + static bfd_boolean
> > > + elf64_x86_64_elf_section_from_bfd_section (bfd *abfd ATTRIBUTE_UNUSED,
> > > + asection *sec, int *retval)
> > > + {
> > > + if (strcmp (bfd_get_section_name (abfd, sec), ".lcommon") == 0
> > > + || strcmp (bfd_get_section_name (abfd, sec), ".lbss") == 0)
> > > + {
> > > + *retval = SHN_X86_64_LCOMMON;
> > > + return TRUE;
> > > + }
> > > + return FALSE;
> > > + }
> >
> > There is no such a section .lcommon. SHN_X86_64_LCOMMON is not a
> > special section index which doesn't have a real section.
>
> I've grabbed this code from other backend, but I do construct those two
> sections later in tc-i386.c:
> + flagword applicable;
> + segT seg;
> + subsegT subseg;
> + /* The lbss section is for local .lcomm symbols. */
> + lbss_section = subseg_new (".lbss", 0);
> + elf_section_flags (lbss_section) |= SHF_X86_64_LARGE;
> +
> + seg = now_seg;
> + subseg = now_subseg;
> + /* This is copied from perform_an_assembly_pass. */
> + applicable = bfd_applicable_section_flags (stdoutput);
> + bfd_set_section_flags (stdoutput, lbss_section, applicable & SEC_ALLOC);
> +
> + subseg_set (seg, subseg);
> +
> + lcom_section = bfd_com_section;
> + lcom_section.name = ".lcommon";
> + lcom_section.output_section = & lcom_section;
> + lcom_section.symbol = & lcom_symbol;
> + lcom_section.symbol_ptr_ptr = & lcom_section.symbol;
> + lcom_symbol = * bfd_com_section.symbol;
> + lcom_symbol.name = ".lcommon";
> + lcom_symbol.section = & lcom_section;
>
> My problem is that those sections are not getting SHN_X86_64_LCOMMON.
> Even if I set it via:
> elf_section_data (lbss_section)->this_idx = SHN_X86_64_LCOMMON;
> This value is later redefined in assign_section_numbers, so what is the
> correct way to arrange the SHN_X86_64_LCOMMON index?
>
I am not sure if any existing ELF target handles the processor
specific common SHN_XXX correctly. You may need some new infrastructure
to support it properly. I will see if I can do something about it.
H.J.