This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: "ld -r" on mixed IR/non-IR objects (


On Tue, Dec 7, 2010 at 3:58 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Tue, Dec 7, 2010 at 3:57 PM, Andrew Pinski <pinskia@gmail.com> wrote:
>> On Tue, Dec 7, 2010 at 3:53 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>> On Tue, Dec 7, 2010 at 3:15 PM, Cary Coutant <ccoutant@google.com> wrote:
>>>>> Here is my proposal. ÂAny comments?
>>>>
>>>> We talked about ld -r a while back during the WHOPR project, and the
>>>> two ways that the linker could work: (1) combine all the .o files and
>>>> use the plugin to run LTRANS on the IR files, producing a pure,
>>>> optimized, object file; and (2) combine the non-IR object files as ld
>>>> -r normally would, and combine that result somehow with the IR from
>>>> the other files, for later optimization. If I remember correctly,
>>>> there was support for both modes of operation. The first mode is
>>>> easily handled with the current design (untested as far as I know --
>>>> there are probably bugs, and I'm not sure if we get the symbol
>>>> visibility correct in those cases).
>>>
>>> We considered it. ÂThe problem is LTO performs the best when
>>> generating the final executable/DSO. ÂThat is we want the full IR in the
>>> output of "ld -r".
>>
>> What happens when ld -r is the final link? ÂThink loadable linux
>> kernel modules and some other stuff that abuse elf relocatable
>> objects?
>>
>
> "ld -plugin ... -r" will be treated as final link.
>

Here is the updated proposal.


-- 
H.J.
---
â 2 kinds of object files
	â non-IR object file has
		Â non-IR sections
	â IR object file has
		Â IR sections
		Â non-IR sections
â The output of "ld -r" with mixed IR/non-IR objects should work with:
	â Compilers/linkers with IR support.
	â Compilers/linkers without IR support.
â Add the mixed object file which has
	â IR sections
	â non-IR sections:
		Â Object codes from IR sections.
		Â Object codes from non-IR object files.
	â Object-only section:
		Â Section name won't be generated by any tools, something like
".objectonly\004".
		Â Contains non-IR object file.
		Â Input is discarded after link.
â Linker action:
	â Classify each input object file:
		â If there is a ".objectonly\004" section, it is a mixed object file.
		â If there is a IR section, it is an IR object file.
		â Otherwise, it is a non-IR object file.
	â Relocatable non-IR link:
		Â Prepare for an object-only output.
		Â Prepare for a regular output.
		Â For each mixed object file:
			â Add IR and non-IR sections to the regular output.
			â For object-only section:
				Â Extract object only file.
				Â Add it to the object-only output.
				Â Discard object-only section.
		Â For each IR object file:
			â Add IR and non-IR sections to the regular output.
		Â For each non-IR object file:
			â Add non-IR sections to the regular output.
			â Add non-IR sections to the object-only output.
		Â Final output:
			â If there are IR objects, non-IR objects and the object-only
output isn't empty:
				Â Put the object-only output into the object-only section.
				Â Add the object-only section to the regular output.
			â Remove the object-only output.
	â Normal link and relocatable IR link:
		Â Prepare for output.
		Â IR link:
			â For each mixed object file:
				Â Compile and add IR sections to the output.
				Â Discard non-IR sections.
				Â Object-only section:
					â Extract object only file.
					â Add it to the output.
					â Discard object-only section.
			â For each IR object file:
				Â Compile and add IR sections to the output.
				Â Discard non-IR sections.
			â For each non-IR object file,
				Â Add non-IR sections to the output.
		Â Non-IR link:
			â For each mixed object file:
				Â Add non-IR sections to the output.
				Â Discard IR sections and object-only section.
			â For each IR object file:
				Â Add non-IR sections to the output.
				Â Discard IR sections .
			â For each non-IR object file:
				Â Add non-IR sections to the output.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]