Attachment – The Yasm Modular Assembler Project

Ticket #102: birds-segment-patch-2.diff

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

a sligtly better version

  • 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        /* XXX could be 16 bytes if the terminator isn't needed , but play safe for now. */ 
     1415        if (strlen(sectname) >= 15) { 
     1416            yasm_error_set(YASM_ERROR_VALUE, 
     1417                           N_("The section name `%s' is too long, max 15 chars"),  
     1418                           sectname); 
     1419            return NULL; 
     1420        } 
     1421        f_segname = "__TEXT"; 
     1422        f_sectname = yasm__xstrdup(sectname); 
     1423        flags = S_ATTR_SOME_INSTRUCTIONS; 
     1424        align = 0; 
     1425        i = -1; /* can be used as indicator further down */ 
     1426    } else { 
     1427        f_segname = section_name_translation[i].seg; 
     1428        f_sectname = section_name_translation[i].sect; 
     1429        flags = section_name_translation[i].flags; 
     1430        align = section_name_translation[i].align; 
    14171431    } 
    14181432 
    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  
    14241433    while ((vp = yasm_vps_next(vp))) { 
    14251434        if (!vp->val) { 
    14261435            yasm_warn_set(YASM_WARN_GENERAL, 
    14271436                          N_("Unrecognized numeric qualifier")); 
    14281437            continue; 
    14291438        } 
    14301439 
    14311440        flags_override = 1; 
    14321441        if (yasm__strcasecmp(vp->val, "align") == 0 && vp->param) { 
    14331442            /*@dependent@ *//*@null@ */ const yasm_intnum *align_expr; 
     
    14481457                               vp->val); 
    14491458                return NULL; 
    14501459            } 
    14511460 
    14521461            /* Check to see if alignment is supported size */ 
    14531462            if (align > 16384) { 
    14541463                yasm_error_set(YASM_ERROR_VALUE, 
    14551464                    N_("macho implementation does not support alignments > 16384")); 
    14561465                return NULL; 
    14571466            } 
    1458         } else 
    1459             yasm_warn_set(YASM_WARN_GENERAL, 
    1460                           N_("Unrecognized qualifier `%s'"), vp->val); 
     1467        } else if (yasm__strcasecmp(vp->val, "segname") == 0) { 
     1468            if (vp->param) { 
     1469                yasm_error_set(YASM_ERROR_VALUE, 
     1470                               N_("The `segname' attribute for section `%s' has a parameter. " 
     1471                                  "Try drop any `=' or similar between the `segname' and the name."), 
     1472                               sectname); 
     1473                return NULL; 
     1474            } 
     1475            vp = yasm_vps_next(vp); 
     1476            if (!vp) { 
     1477                yasm_error_set(YASM_ERROR_VALUE, 
     1478                               N_("The `segname' attribute for section `%s' is missing the name"), 
     1479                               sectname); 
     1480                return NULL; 
     1481            } 
     1482            if (strlen(vp->val) > 15) { 
     1483                yasm_error_set(YASM_ERROR_VALUE, 
     1484                               N_("The segment name `%s' for section `%s' is too long, max 15 chars"),  
     1485                               sectname, vp->val); 
     1486                return NULL; 
     1487            } 
     1488            f_segname = yasm__xstrdup(vp->val); 
     1489        } else { 
     1490            yasm_error_set(YASM_ERROR_VALUE, 
     1491                           N_("Unrecognized qualifier `%s' or missing parameter in the section defintion of `%s'"),  
     1492                           vp->val, sectname); 
     1493            return NULL; 
     1494        } 
    14611495    } 
    14621496 
    14631497    retval = yasm_object_get_general(object, sectname, 0, align, 1, resonly, 
    14641498                                     &isnew, line); 
    14651499 
    14661500    if (isnew) 
    14671501        msd = macho_objfmt_init_new_section(object, retval, sectname, line); 
    14681502    else 
    14691503        msd = yasm_section_get_data(retval, &macho_section_data_cb); 
    14701504