summaryrefslogtreecommitdiffstats
path: root/linker
diff options
context:
space:
mode:
authorIliyan Malchev <malchev@google.com>2009-10-19 14:25:17 -0700
committerIliyan Malchev <malchev@google.com>2009-10-19 18:10:35 -0700
commitbb9eedeff4ddc4550991eb4511003bda8672d6c4 (patch)
tree8d3769c0545e031410ba3fa16394a3057016efb8 /linker
parentaf7315acf6a3a5ac329b04cb543b5d8a95dc26f1 (diff)
downloadbionic-bb9eedeff4ddc4550991eb4511003bda8672d6c4.zip
bionic-bb9eedeff4ddc4550991eb4511003bda8672d6c4.tar.gz
bionic-bb9eedeff4ddc4550991eb4511003bda8672d6c4.tar.bz2
bionic/linker: make the buddy allocator compute max_order on its own
Signed-off-by: Iliyan Malchev <malchev@google.com>
Diffstat (limited to 'linker')
-rw-r--r--linker/ba.c7
-rw-r--r--linker/linker.c2
2 files changed, 8 insertions, 1 deletions
diff --git a/linker/ba.c b/linker/ba.c
index 8534919..db49c4b 100644
--- a/linker/ba.c
+++ b/linker/ba.c
@@ -41,9 +41,16 @@
#define BA_START_ADDR(index) (BA_OFFSET(index) + ba->base)
#define BA_LEN(index) ((1 << BA_ORDER(index)) * ba->min_alloc)
+static unsigned long ba_order(struct ba *ba, unsigned long len);
+
void ba_init(struct ba *ba)
{
int i, index = 0;
+
+ unsigned long max_order = ba_order(ba, ba->size);
+ if (ba->max_order == 0 || ba->max_order > max_order)
+ ba->max_order = max_order;
+
for (i = sizeof(ba->num_entries) * 8 - 1; i >= 0; i--) {
if (ba->num_entries & 1<<i) {
BA_ORDER(index) = i;
diff --git a/linker/linker.c b/linker/linker.c
index 07c7d78..5090b11 100644
--- a/linker/linker.c
+++ b/linker/linker.c
@@ -98,7 +98,7 @@ static struct ba ba_prelink = {
.base = LIBBASE,
.size = LIBLAST - LIBBASE,
.min_alloc = LIBINC,
- .max_order = 128,
+ /* max_order will be determined automatically */
.bitmap = ba_prelink_bitmap,
.num_entries = sizeof(ba_prelink_bitmap)/sizeof(ba_prelink_bitmap[0]),
};