This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc 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: FreeBSD port (51): creation of ld.so.1


> On FreeBSD, only executables [ET_EXEC] can be executed by the kernel, not
> shared libraries [ET_DYN]. Therefore the DSO ld.so.1 has to be transformed
> from a shared library to an executable when it is built. 

But it should be ET_DYN to be used as the ELF program interpreter.
I think what you really want is to transform ld.so into an executable
in a different file, and use that file in $(built-program-command).

> Here is a patch
> to allow a hook called POSTPROCESS_LD_SO, as well as additional Makefile
> dependencies for ld.so.1. This patch is a nop for other platforms.

This is not the right way to get this result.  (For one thing, your change
puts the "hook" variable reference after a ":" command, which makes it
a no-op in the shell.)  You should not add new commands to an existing
target that post-process a file in place.  It is never robust to have such
command sequences in a makefile.  If, for example, the make were killed
after the link but before the post-processing step, the output file would
be left unfinished but the next make would think it was built fine.
If you have additional commands in a single rule, the right thing to do
is make the intermediate stages use a temporary file name.

However, the really right thing to do is to use a separate target rule,
i.e.:

$(objpfx)ld.so.run: $(objpfx)ld.so
	... -o $@

You can just add this rule in sysdeps/.../Makefile.


> 2002-09-04  Bruno Haible  <bruno@clisp.org>
> 
> 	* elf/Makefile ($(objpfx)ld.so): Allow additional dependencies.
> 	Invoke POSTPROCESS_LD_SO if defined.
> 
> diff -r -c3 glibc-20020828.bak/elf/Makefile glibc-20020828/elf/Makefile
> *** glibc-20020828.bak/elf/Makefile	Wed Aug 28 12:51:02 2002
> --- glibc-20020828/elf/Makefile	Fri Aug 30 11:08:48 2002
> ***************
> *** 179,187 ****
>   		      -e 's/\. = 0 + SIZEOF_HEADERS;/& _begin = . - SIZEOF_HEADERS;/' \
>   		  > $@.lds
>   	$(LINK.o) -nostdlib -nostartfiles -shared -o $@ $(LDFLAGS-rtld)	\
> ! 		  $(filter-out $(map-file),$^) $(load-map-file)		\
>   		  -Wl,-soname=$(rtld-installed-name) -T $@.lds
>   	rm -f $@.lds
>   
>   # interp.c exists just to get this string into the libraries.
>   CFLAGS-interp.c = -D'RUNTIME_LINKER="$(slibdir)/$(rtld-installed-name)"'
> --- 179,189 ----
>   		      -e 's/\. = 0 + SIZEOF_HEADERS;/& _begin = . - SIZEOF_HEADERS;/' \
>   		  > $@.lds
>   	$(LINK.o) -nostdlib -nostartfiles -shared -o $@ $(LDFLAGS-rtld)	\
> ! 		  $(filter-out $(map-file), $(objpfx)librtld.os $(ld-map)) \
> ! 		  $(load-map-file)					\
>   		  -Wl,-soname=$(rtld-installed-name) -T $@.lds
>   	rm -f $@.lds
> + 	: $(POSTPROCESS_LD_SO)
>   
>   # interp.c exists just to get this string into the libraries.
>   CFLAGS-interp.c = -D'RUNTIME_LINKER="$(slibdir)/$(rtld-installed-name)"'


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