diff options
author | Richard Lowe <richlowe@richlowe.net> | 2011-03-04 15:27:25 -0500 |
---|---|---|
committer | Richard Lowe <richlowe@richlowe.net> | 2011-03-04 15:27:25 -0500 |
commit | c8937b0da86ffcdeb5a328afe14cb7bb0a5a4d2b (patch) | |
tree | 73fee0679d98290be0ccb3ddd1736e1dba1a8158 /usr/src | |
parent | 5ead3ed965903bf336d9acc050feeb2cc9965d95 (diff) | |
download | illumos-joyent-c8937b0da86ffcdeb5a328afe14cb7bb0a5a4d2b.tar.gz |
308 ld may misalign sections only preceded by empty sections
Reviewed by: gwr@nexenta.com
Reviewed by: garrett@nexenta.com
Reviewed by: trisk@opensolaris.org
Approved by: garrett@nexenta.com
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/cmd/sgs/libld/common/outfile.c | 39 | ||||
-rw-r--r-- | usr/src/cmd/sgs/packages/common/SUNWonld-README | 9 |
2 files changed, 48 insertions, 0 deletions
diff --git a/usr/src/cmd/sgs/libld/common/outfile.c b/usr/src/cmd/sgs/libld/common/outfile.c index 2da01f3d51..a817675ece 100644 --- a/usr/src/cmd/sgs/libld/common/outfile.c +++ b/usr/src/cmd/sgs/libld/common/outfile.c @@ -24,6 +24,8 @@ * All Rights Reserved * * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + * + * Copyright 2011, Richard Lowe. */ /* @@ -428,6 +430,7 @@ ld_create_outfile(Ofl_desc *ofl) Phdr *phdr = &(sgp->sg_phdr); Word ptype = phdr->p_type; Aliste idx2; + Os_desc *nonempty = NULL; /* First non-empty section */ /* * Count the number of segments that will go in the program @@ -670,6 +673,10 @@ ld_create_outfile(Ofl_desc *ofl) data->d_align = (size_t)align; } + + if ((data->d_size != 0) && (nonempty == NULL)) { + nonempty = osp; + } } /* @@ -678,6 +685,38 @@ ld_create_outfile(Ofl_desc *ofl) */ osp->os_szoutrels = 0; } + + /* + * We need to raise the alignment of any empty sections at the + * start of a segment to be at least as aligned as the first + * non-empty section, such that the empty and first non-empty + * sections are placed at the same offset. + */ + if (nonempty != NULL) { + Elf_Data *ne = NULL; + Xword pad_align = 1; + + ne = elf_getdata(nonempty->os_scn, NULL); + assert(ne != NULL); + + do { + pad_align = ld_lcm(pad_align, ne->d_align); + ne = elf_getdata(nonempty->os_scn, ne); + } while (ne != NULL); + + for (APLIST_TRAVERSE(sgp->sg_osdescs, idx2, osp)) { + Elf_Data *d = NULL; + + /* Stop at the first non-empty section */ + if (osp == nonempty) + break; + + d = elf_getdata(osp->os_scn, NULL); + assert(d != NULL); + + d->d_align = pad_align; + } + } } /* diff --git a/usr/src/cmd/sgs/packages/common/SUNWonld-README b/usr/src/cmd/sgs/packages/common/SUNWonld-README index 280cc30960..67c224ca95 100644 --- a/usr/src/cmd/sgs/packages/common/SUNWonld-README +++ b/usr/src/cmd/sgs/packages/common/SUNWonld-README @@ -1622,3 +1622,12 @@ Bugid Risk Synopsis 6975290 ld mishandles GOT relocation against local ABS symbol 6972860 ld should provide user guidance to improve objects (D) PSARC/2010/312 Link-editor guidance +-------------------------------------------------------------------------------- + +-------------- +Illumos +-------------- +Bugid Risk Synopsis +================================================================================ + +308 ld may misalign sections only preceded by empty sections |