bionic/linker: make the buddy allocator compute max_order on its own
Signed-off-by: Iliyan Malchev <malchev@google.com>
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 @@
.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]),
};