more sysroot support in the linker

Nick Clifton nickc@redhat.com
Mon Mar 24 19:08:00 GMT 2003


Hi Alex,

> Tested on athlon-pc-linux-gnu-x-mips64-linux-gnu.  Ok to install?
> 
> Index: ld/ChangeLog
> from  Alexandre Oliva  <aoliva@redhat.com>
> 
> 	* ldmain.h (ld_canon_sysroot, ld_canon_sysroot_len): Declare.
> 	* ldmain.c (ld_canon_sysroot, ld_canon_sysroot_len): Define.
> 	(main): Initialize them.
> 	* ldfile.c: Include pathnames.h.
> 	(is_sysrooted_pathname): New.
> 	(ldfile_add_library_path): Use it.
> 	(ldfile_open_file_search): Likewise.  Use IS_ABSOLUTE_PATH.  Don't
> 	search_dirs if given an absolute pathname.
> 	(ldfile_open_file): Issue error message for sysrooted
> 	absolute pathnames.

Sorry - the patch needs tidying up first.

There are two problems:

> +++ ld/ldfile.c 22 Mar 2003 11:55:01 -0000
> @@ -35,6 +35,7 @@ Software Foundation, 59 Temple Place - S
>  #include "ldlex.h"
>  #include "ldemul.h"
>  #include "libiberty.h"
> +#include "filenames.h"

You are adding a new #include to ldfile.c but not updating Makefile.am
with the new dependency.

> +static bfd_boolean
> +is_sysrooted_pathname (name, notsame)
> +     const char *name;
> +     bfd_boolean notsame;
> +{
> +  char *realname = ld_canon_sysroot ? lrealpath (name) : NULL;
> +  int len;
> +  bfd_boolean result;
> +
> +  if (! realname)
> +    return FALSE;
> +  
> +  if (((! notsame && len == ld_canon_sysroot_len)
> +       || (len >= ld_canon_sysroot_len
> +	   && IS_DIR_SEPARATOR (realname[ld_canon_sysroot_len])
> +	   && (realname[ld_canon_sysroot_len] = '\0') == '\0'))
> +      && FILENAME_CMP (ld_canon_sysroot, realname) == 0)
> +    result = TRUE;
> +  else
> +    result = FALSE;
> +
> +  if (realname)
> +    free (realname);
> +
> +  return result;
> +}

The variable 'len' is used without being initialised.


Cheers
        Nick



More information about the Binutils mailing list