Attachment – The Yasm Modular Assembler Project

Ticket #102: birds-segment-patch.diff

File birds-segment-patch.diff, 3.8 kB (added by bird-yasm-spam@…, 19 months ago)

Patch proposal (sorry about the missing tabs).

  • yasm-r1818/modules/objfmts/macho/macho-objfmt.c

    diff -rU10 virgin/yasm-r1818/modules/objfmts/macho/macho-objfmt.c yasm-r1818/modules/objfmts/macho/macho-objfmt.c
    old new  
    14041404 
    14051405    sectname = vp->val; 
    14061406 
    14071407    /* translate .text,.data,.bss to __text,__data,__bss... */ 
    14081408    for (i=0; i<NELEMS(section_name_translation); i++) { 
    14091409        if (yasm__strcasecmp(sectname, section_name_translation[i].in) == 0) 
    14101410            break; 
    14111411    } 
    14121412 
    14131413    if (i == NELEMS(section_name_translation)) { 
    1414         yasm_warn_set(YASM_WARN_GENERAL, 
    1415                       N_("Unknown section type, defaulting to .text")); 
    1416         i = 0; 
     1414        if (strlen(sectname) >= 16) { 
     1415            yasm_error_set(YASM_ERROR_VALUE, 
     1416                           N_("The section name `%s' is too long, max 16 chars"),  
     1417                           sectname); 
     1418            return NULL; 
     1419        } 
     1420        f_segname = "__TEXT"; 
     1421        f_sectname = yasm__xstrdup(sectname); 
     1422        flags = S_ATTR_SOME_INSTRUCTIONS; 
     1423        align = 0; 
     1424        i = -1; /* can be used as indicator further down */ 
     1425    } else { 
     1426        f_segname = section_name_translation[i].seg; 
     1427        f_sectname = section_name_translation[i].sect; 
     1428        flags = section_name_translation[i].flags; 
     1429        align = section_name_translation[i].align; 
    14171430    } 
    14181431 
    1419     f_segname = section_name_translation[i].seg; 
    1420     f_sectname = section_name_translation[i].sect; 
    1421     flags = section_name_translation[i].flags; 
    1422     align = section_name_translation[i].align; 
    1423  
    14241432    while ((vp = yasm_vps_next(vp))) { 
    14251433        if (!vp->val) { 
    14261434            yasm_warn_set(YASM_WARN_GENERAL, 
    14271435                          N_("Unrecognized numeric qualifier")); 
    14281436            continue; 
    14291437        } 
    14301438 
    14311439        flags_override = 1; 
    14321440        if (yasm__strcasecmp(vp->val, "align") == 0 && vp->param) { 
    14331441            /*@dependent@ *//*@null@ */ const yasm_intnum *align_expr; 
     
    14481456                               vp->val); 
    14491457                return NULL; 
    14501458            } 
    14511459 
    14521460            /* Check to see if alignment is supported size */ 
    14531461            if (align > 16384) { 
    14541462                yasm_error_set(YASM_ERROR_VALUE, 
    14551463                    N_("macho implementation does not support alignments > 16384")); 
    14561464                return NULL; 
    14571465            } 
    1458         } else 
    1459             yasm_warn_set(YASM_WARN_GENERAL, 
    1460                           N_("Unrecognized qualifier `%s'"), vp->val); 
     1466        } else if (yasm__strcasecmp(vp->val, "segname") == 0) { 
     1467            if (vp->param) { 
     1468                yasm_error_set(YASM_ERROR_VALUE, 
     1469                               N_("The `segname' attribute for section `%s' has a parameter. " 
     1470                                  "Try drop any `=' or similar between the `segname' and the name."), 
     1471                               sectname); 
     1472                return NULL; 
     1473            } 
     1474            vp = yasm_vps_next(vp); 
     1475            if (!vp) { 
     1476                yasm_error_set(YASM_ERROR_VALUE, 
     1477                               N_("The `segname' attribute for section `%s' is missing the name"), 
     1478                               sectname); 
     1479                return NULL; 
     1480            } 
     1481            if (strlen(vp->val) >= 16) { 
     1482                yasm_error_set(YASM_ERROR_VALUE, 
     1483                               N_("The segment name `%s' for section `%s' is too long, max 16 chars"),  
     1484                               sectname, vp->val); 
     1485                return NULL; 
     1486            } 
     1487            f_segname = yasm__xstrdup(vp->val); 
     1488        } else { 
     1489            yasm_error_set(YASM_ERROR_VALUE, 
     1490                           N_("Unrecognized qualifier `%s' or missing parameter in the section defintion of `%s'"),  
     1491                           vp->val, sectname); 
     1492            return NULL; 
     1493        } 
    14611494    } 
    14621495 
    14631496    retval = yasm_object_get_general(object, sectname, 0, align, 1, resonly, 
    14641497                                     &isnew, line); 
    14651498 
    14661499    if (isnew) 
    14671500        msd = macho_objfmt_init_new_section(object, retval, sectname, line); 
    14681501    else 
    14691502        msd = yasm_section_get_data(retval, &macho_section_data_cb); 
    14701503