1/* Section hash table implementation.
2   Copyright (C) 2001, 2002 Red Hat, Inc.
3   Written by Ulrich Drepper <drepper@redhat.com>, 2001.
4
5   This program is Open Source software; you can redistribute it and/or
6   modify it under the terms of the Open Software License version 1.0 as
7   published by the Open Source Initiative.
8
9   You should have received a copy of the Open Software License along
10   with this program; if not, you may obtain a copy of the Open Software
11   License version 1.0 from http://www.opensource.org/licenses/osl.php or
12   by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
13   3001 King Ranch Road, Ukiah, CA 95482.   */
14
15#ifdef HAVE_CONFIG_H
16# include <config.h>
17#endif
18
19#include <string.h>
20
21#include <elf-knowledge.h>
22#include <ld.h>
23
24
25/* Comparison function for sections.  */
26static int
27scnhead_compare (struct scnhead *one, struct scnhead *two)
28{
29  int result = strcmp (one->name, two->name);
30
31  if (result == 0)
32    {
33      result = one->type - two->type;
34
35      if (result == 0)
36	{
37	  GElf_Xword diff = (SH_FLAGS_IMPORTANT (one->flags)
38			     - SH_FLAGS_IMPORTANT (two->flags));
39	  result = diff < 0 ? -1 : diff == 0 ? 0 : 1;
40
41	  if (result == 0)
42	    {
43	      result = one->entsize - two->entsize;
44
45	      if (result == 0)
46		{
47		  result = (one->grp_signature == NULL
48			    ? (two->grp_signature == NULL ? 0 : -1)
49			    : (two->grp_signature == NULL
50			       ? 1 : strcmp (one->grp_signature,
51					     two->grp_signature)));
52
53		  if (result == 0)
54		    result = one->kind - two->kind;
55		}
56	    }
57	}
58    }
59
60  return result;
61}
62
63/* Definitions for the section hash table.  */
64#define TYPE struct scnhead *
65#define NAME ld_section_tab
66#define ITERATE 1
67#define COMPARE(a, b) scnhead_compare (a, b)
68
69#include "../lib/dynamicsizehash.c"
70