diff options
-rw-r--r-- | output/outelf32.c | 7 | ||||
-rw-r--r-- | output/outelf64.c | 9 |
2 files changed, 11 insertions, 5 deletions
diff --git a/output/outelf32.c b/output/outelf32.c index e021ba74..ffd59dbf 100644 --- a/output/outelf32.c +++ b/output/outelf32.c @@ -333,7 +333,8 @@ static int elf_make_section(char *name, int type, int flags, int align) static int32_t elf_section_names(char *name, int pass, int *bits) { char *p; - int flags_and, flags_or, type, align, i; + unsigned flags_and, flags_or; + int type, align, i; /* * Default is 32 bits. @@ -427,7 +428,9 @@ static int32_t elf_section_names(char *name, int pass, int *bits) sects[i]->flags &= ~flags_and; sects[i]->flags |= flags_or; } else if (pass == 1) { - if (type || align || flags_and) + if ((type && sects[i]->type != type) + || (align && sects[i]->align != align) + || (flags_and && ((sects[i]->flags & flags_and) != flags_or))) error(ERR_WARNING, "section attributes ignored on" " redeclaration of section `%s'", name); } diff --git a/output/outelf64.c b/output/outelf64.c index 3ef19a24..6ee56343 100644 --- a/output/outelf64.c +++ b/output/outelf64.c @@ -346,7 +346,8 @@ static int elf_make_section(char *name, int type, int flags, int align) static int32_t elf_section_names(char *name, int pass, int *bits) { char *p; - int flags_and, flags_or, type, align, i; + unsigned flags_and, flags_or; + int type, align, i; /* * Default is 64 bits. @@ -440,8 +441,10 @@ static int32_t elf_section_names(char *name, int pass, int *bits) sects[i]->flags &= ~flags_and; sects[i]->flags |= flags_or; } else if (pass == 1) { - if (type || align || flags_and) - error(ERR_WARNING, "section attributes ignored on" + if ((type && sects[i]->type != type) + || (align && sects[i]->align != align) + || (flags_and && ((sects[i]->flags & flags_and) != flags_or))) + error(ERR_WARNING, "incompatible section attributes ignored on" " redeclaration of section `%s'", name); } |