Nishanth Aravamudan | 3 Apr 2007 03:27
Picon
Favicon

[RFC][PATCH] ppc: rework plt detection

ppc: rework plt detection

We currently emit LONG(0) into the .plt section of relinked ppc binaries
to make it appear in the filesz (on-disk) portion of the data/bss
segment. This is a problem, however, for powerpc64, where the ABI
specifies that the .plt section is NOBITS (x86 and x86_64 mark the .plt
PROGBITS). Given that the program is being relinked to begin with,
however, it seems logical to simply add a tag, similar to
__executable_start, to make finding the "libhuge" filesz easy to find.
Do exactly this, via __libhuge_filesz, and skip the extracopy detection
if this symbol is defined. Tested on powerpc64.

Signed-off-by: Nishanth Aravamudan <nacc <at> us.ibm.com>

diff --git a/elflink.c b/elflink.c
index 5058248..00b403a 100644
--- a/elflink.c
+++ b/elflink.c
 <at>  <at>  -414,6 +414,7  <at>  <at>  static void get_extracopy(struct seg_info *seg, Elf_Phdr *phdr, int phnum)
 	int ret, numsyms, found_sym = 0;
 	void *start, *end, *start_orig, *end_orig;
 	void *sym_start, *sym_end;
+	extern void __libhuge_filesz __attribute__((weak));

 	end_orig = seg->vaddr + seg->memsz;
 	start_orig = seg->vaddr + seg->filesz;
 <at>  <at>  -422,6 +423,13  <at>  <at>  static void get_extracopy(struct seg_info *seg, Elf_Phdr *phdr, int phnum)
 	if (!minimal_copy)
 		goto bail2;

(Continue reading)

Adam Litke | 3 Apr 2007 16:01
Picon
Favicon

Re: [RFC][PATCH] ppc: rework plt detection

On Mon, 2007-04-02 at 18:27 -0700, Nishanth Aravamudan wrote:
> ppc: rework plt detection
> 
> We currently emit LONG(0) into the .plt section of relinked ppc binaries
> to make it appear in the filesz (on-disk) portion of the data/bss
> segment. This is a problem, however, for powerpc64, where the ABI
> specifies that the .plt section is NOBITS (x86 and x86_64 mark the .plt
> PROGBITS). Given that the program is being relinked to begin with,
> however, it seems logical to simply add a tag, similar to
> __executable_start, to make finding the "libhuge" filesz easy to find.
> Do exactly this, via __libhuge_filesz, and skip the extracopy detection
> if this symbol is defined. Tested on powerpc64.

Looks good to me... 

What do you think about adding some comments into the linker scripts
here so it will be easy to remember what this is for later?

> diff --git a/ldscripts/elf32ppclinux.xBDT b/ldscripts/elf32ppclinux.xBDT
> index f30bd3b..2dd8e8f 100644
> --- a/ldscripts/elf32ppclinux.xBDT
> +++ b/ldscripts/elf32ppclinux.xBDT
>  <at>  <at>  -163,7 +163,8  <at>  <at>  SECTIONS
>  /*  . = DATA_SEGMENT_RELRO_END (0, .); */
>    /* Ensure the plt appears in the on-disk portion of the binary so it
>     * will be copied during hugetlb remapping */
> -  .plt            :  { *(.plt) LONG(0) } :hdata
> +  .plt            :  { *(.plt) } :hdata
> +  __libhuge_filesz = .;
>    .data           :
(Continue reading)

Nishanth Aravamudan | 3 Apr 2007 16:31
Picon
Favicon

[RFC][PATCH v2] ppc: rework plt detection

On 03.04.2007 [09:01:34 -0500], Adam Litke wrote:
> On Mon, 2007-04-02 at 18:27 -0700, Nishanth Aravamudan wrote:
> > ppc: rework plt detection
> > 
> > We currently emit LONG(0) into the .plt section of relinked ppc binaries
> > to make it appear in the filesz (on-disk) portion of the data/bss
> > segment. This is a problem, however, for powerpc64, where the ABI
> > specifies that the .plt section is NOBITS (x86 and x86_64 mark the .plt
> > PROGBITS). Given that the program is being relinked to begin with,
> > however, it seems logical to simply add a tag, similar to
> > __executable_start, to make finding the "libhuge" filesz easy to find.
> > Do exactly this, via __libhuge_filesz, and skip the extracopy detection
> > if this symbol is defined. Tested on powerpc64.
> 
> Looks good to me... 
> 
> What do you think about adding some comments into the linker scripts
> here so it will be easy to remember what this is for later?

Updated patch below:

ppc: rework plt detection

We currently emit LONG(0) into the .plt section to make it appear in the
filesz (on-disk) portion of the data/bss segment. This is a problem,
however, for powerpc64, where the ABI specifies that the .plt section is
NOBITS (x86 and x86_64 mark the .plt PROGBITS). Given that the program
is being relinked to begin with, however, it seems logical to simply add
a tag, similar to __executable_start, to make finding the "libhuge"
filesz easy to find. Do exactly this, via __libhuge_filesz, and skip the
(Continue reading)

Adam Litke | 3 Apr 2007 16:49
Picon
Favicon

Re: [RFC][PATCH v2] ppc: rework plt detection

On Tue, 2007-04-03 at 07:31 -0700, Nishanth Aravamudan wrote:
> On 03.04.2007 [09:01:34 -0500], Adam Litke wrote:
> > On Mon, 2007-04-02 at 18:27 -0700, Nishanth Aravamudan wrote:
> > > ppc: rework plt detection
> > > 
> > > We currently emit LONG(0) into the .plt section of relinked ppc binaries
> > > to make it appear in the filesz (on-disk) portion of the data/bss
> > > segment. This is a problem, however, for powerpc64, where the ABI
> > > specifies that the .plt section is NOBITS (x86 and x86_64 mark the .plt
> > > PROGBITS). Given that the program is being relinked to begin with,
> > > however, it seems logical to simply add a tag, similar to
> > > __executable_start, to make finding the "libhuge" filesz easy to find.
> > > Do exactly this, via __libhuge_filesz, and skip the extracopy detection
> > > if this symbol is defined. Tested on powerpc64.
> > 
> > Looks good to me... 
> > 
> > What do you think about adding some comments into the linker scripts
> > here so it will be easy to remember what this is for later?
> 
> Updated patch below:
> 
> 
> ppc: rework plt detection
> 
> We currently emit LONG(0) into the .plt section to make it appear in the
> filesz (on-disk) portion of the data/bss segment. This is a problem,
> however, for powerpc64, where the ABI specifies that the .plt section is
> NOBITS (x86 and x86_64 mark the .plt PROGBITS). Given that the program
> is being relinked to begin with, however, it seems logical to simply add
(Continue reading)

Picon
Favicon

税务代理

尊敬的财务、负责人、
             您好!
    广东金通财税咨询服务有限公司一直从事国内税务代理行业,本司现对外代开[国、地]税发票。税率优惠、本司所提供发票均可上网查询或到税务抵扣抵税。
                               
   
                                                                           祥情请您来电咨询!
 
                                                                                      顺祝商祺!
 
                                                   联系人:胡小姐
                                                   
                                                   手  机:13826563095
           
                                   
                                                      

                                               
Attachment (ad2.gif): application/octet-stream, 8 KiB
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Libhugetlbfs-devel mailing list
Libhugetlbfs-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel
Nishanth Aravamudan | 12 Apr 2007 19:43
Picon
Favicon

[PATCH] elflink: fix-up DEBUG with plt rework

elflink: fix-up DEBUG with plt rework

If the libhuge_filesz symbol is used to find the end of the extracopy
area, and HUGETLB_DEBUG is set in the environment, we don't do anything,
because the found label skips the call to check_bss(). Fix this by
moving the label up a few lines.

Signed-off-by: Nishanth Aravamudan <nacc <at> us.ibm.com>

diff --git a/elflink.c b/elflink.c
index 00b403a..42aa7cc 100644
--- a/elflink.c
+++ b/elflink.c
 <at>  <at>  -467,10 +467,10  <at>  <at>  static void get_extracopy(struct seg_info *seg, Elf_Phdr *phdr, int phnum)
 			end = sym_end;
 	}

+found:
 	if (__debug)
 		check_bss(end, end_orig);

-found:
 	if (found_sym) {
 		/* Return the copy window */
 		seg->extra_vaddr = start;

--

-- 
Nishanth Aravamudan <nacc <at> us.ibm.com>
IBM Linux Technology Center

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Nishanth Aravamudan | 13 Apr 2007 01:36
Picon
Favicon

[PATCH v2] elflink: fix-up DEBUG with plt rework

elflink: fix-up DEBUG with plt rework

If the libhuge_filesz symbol is used to find the end of the extracopy
area, and HUGETLB_DEBUG is set in the environment, we don't do anything,
because the found label skips the call to check_bss(). Also,
__libhuge_filez should only be used if its address is greater than that
found by the criss-cross extracopy algorithm. Fix both issues by moving
the check for libhuge_filesz below the algorithm and removing the found
label.

Signed-off-by: Nishanth Aravamudan <nacc <at> us.ibm.com>

--
Adam, if you want to review and provide your Ack for this patch, too,
I'll combine it with the original one before requesting a pull.

diff --git a/elflink.c b/elflink.c
index 00b403a..92a8a96 100644
--- a/elflink.c
+++ b/elflink.c
 <at>  <at>  -423,13 +423,6  <at>  <at>  static void get_extracopy(struct seg_info *seg, Elf_Phdr *phdr, int phnum)
 	if (!minimal_copy)
 		goto bail2;

-	if (&__libhuge_filesz) {
-		found_sym = 1;
-		start = start_orig;
-		end = &__libhuge_filesz;
-		goto found;
-	}
-
 	/* Find dynamic program header */
 	ret = find_dynamic(&dyntab, phdr, phnum);
 	if (ret < 0)
 <at>  <at>  -467,10 +460,18  <at>  <at>  static void get_extracopy(struct seg_info *seg, Elf_Phdr *phdr, int phnum)
 			end = sym_end;
 	}

+	if (&__libhuge_filesz > end) {
+		/* be careful if the algorithm didn't find any symbols
+		 * to copy */
+		if (start == end_orig)
+			start = start_orig;
+		end = &__libhuge_filesz;
+		DEBUG("Found __libhuge_filesz at %p\n", &__libhuge_filesz);
+	}
+
 	if (__debug)
 		check_bss(end, end_orig);

-found:
 	if (found_sym) {
 		/* Return the copy window */
 		seg->extra_vaddr = start;

--

-- 
Nishanth Aravamudan <nacc <at> us.ibm.com>
IBM Linux Technology Center

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Picon
Favicon

税务代理

尊敬的财务、负责人、
             您好!
    广东金通财税咨询服务有限公司一直从事国内税务代理行业,本司现对外代开[国、地]税发票。税率优惠、本司所提供发票均可上网查询或到税务抵扣抵税。
                               
   
                                                                           祥情请您来电咨询!
 
                                                                                      顺祝商祺!
 
                                                   联系人:刘坦先生
                                                   
                                                   手  机:13826583120
           
                                   
                                                      

                                               
Attachment (ad0.gif): application/octet-stream, 6180 bytes
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Libhugetlbfs-devel mailing list
Libhugetlbfs-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel
Jon Tollefson | 16 Apr 2007 17:57
Picon

[PATCH] elflink: remove redundant code

elflink: remove redundant code

The checking of fds >0 is not needed because it is already done earlier 
in the function (find_or_prepare_shared_file) and control leaves the 
function before there is any chance for it to hit the fail: label.

Signed-off-by: Jon Tollefson <kniht <at> linux.vnet.ibm.com>

diff --git a/elflink.c b/elflink.c
index 03b79db..50d2180 100644
--- a/elflink.c
+++ b/elflink.c
 <at>  <at>  -704,8 +704,6  <at>  <at>  static int find_or_prepare_shared_file(s
                              " failure: %s\n", tmp_path, strerror(errno));
                close(fdx);
        }
-       if (fds > 0)
-               close(fds);

        return -1;
 }

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
David Gibson | 17 Apr 2007 03:16
Picon

Re: [RFC][PATCH v2] ppc: rework plt detection

On Tue, Apr 03, 2007 at 07:31:09AM -0700, Nishanth Aravamudan wrote:
> On 03.04.2007 [09:01:34 -0500], Adam Litke wrote:
> > On Mon, 2007-04-02 at 18:27 -0700, Nishanth Aravamudan wrote:
> > > ppc: rework plt detection
> > > 
> > > We currently emit LONG(0) into the .plt section of relinked ppc binaries
> > > to make it appear in the filesz (on-disk) portion of the data/bss
> > > segment. This is a problem, however, for powerpc64, where the ABI
> > > specifies that the .plt section is NOBITS (x86 and x86_64 mark the .plt
> > > PROGBITS). Given that the program is being relinked to begin with,
> > > however, it seems logical to simply add a tag, similar to
> > > __executable_start, to make finding the "libhuge" filesz easy to find.
> > > Do exactly this, via __libhuge_filesz, and skip the extracopy detection
> > > if this symbol is defined. Tested on powerpc64.
> > 
> > Looks good to me... 
> > 
> > What do you think about adding some comments into the linker scripts
> > here so it will be easy to remember what this is for later?
> 
> Updated patch below:
> 
> 
> ppc: rework plt detection
> 
> We currently emit LONG(0) into the .plt section to make it appear in the
> filesz (on-disk) portion of the data/bss segment. This is a problem,
> however, for powerpc64, where the ABI specifies that the .plt section is
> NOBITS (x86 and x86_64 mark the .plt PROGBITS). Given that the program
> is being relinked to begin with, however, it seems logical to simply add
> a tag, similar to __executable_start, to make finding the "libhuge"
> filesz easy to find. Do exactly this, via __libhuge_filesz, and skip the
> extracopy detection if this symbol is defined. Tested on powerpc64.

Nice idea, definitely neater than the LONG(0) thing.  However, I don't
see how it safely lets up bypass extracopy detection - the stdin,
stdout variables that libc initializes will still lie in the BSS
section after the __libhuge_filesz symbol.

> diff --git a/elflink.c b/elflink.c
> index 5058248..00b403a 100644
> --- a/elflink.c
> +++ b/elflink.c
>  <at>  <at>  -414,6 +414,7  <at>  <at>  static void get_extracopy(struct seg_info *seg, Elf_Phdr *phdr, int phnum)
>  	int ret, numsyms, found_sym = 0;
>  	void *start, *end, *start_orig, *end_orig;
>  	void *sym_start, *sym_end;
> +	extern void __libhuge_filesz __attribute__((weak));
>  
>  	end_orig = seg->vaddr + seg->memsz;
>  	start_orig = seg->vaddr + seg->filesz;
>  <at>  <at>  -422,6 +423,13  <at>  <at>  static void get_extracopy(struct seg_info *seg, Elf_Phdr *phdr, int phnum)
>  	if (!minimal_copy)
>  		goto bail2;
>  
> +	if (&__libhuge_filesz) {
> +		found_sym = 1;
> +		start = start_orig;
> +		end = &__libhuge_filesz;
> +		goto found;

Hrm... I don' think this is a reasonable use of a goto.  I'd prefer to
see the other logic in an else branch here.

--

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

Gmane