ldsegs.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * ldsegs.h Data for 'ldrdf' to determine what to do with different
  3. * types of segment. This may be useful in other contexts also.
  4. */
  5. #ifndef RDOFF_LDSEGS_H
  6. #define RDOFF_LDSEGS_H 1
  7. struct segconfig {
  8. uint16_t typelow, typehi; /* range of seg nos for which this is valid */
  9. char *typedesc; /* a description of the segment type */
  10. uint16_t dowhat; /* one of the SEG_xxxx values below */
  11. uint16_t mergetype; /* if SEG_MERGE what type segment do we merge
  12. with?
  13. 0 -> same type of segment. This type is also
  14. used with SEG_NEWSEG. */
  15. };
  16. #define SEG_IGNORE 0
  17. #define SEG_NEWSEG 1
  18. #define SEG_MERGE 2
  19. #define SEGCONFIGMAX 11
  20. struct segconfig sconft[SEGCONFIGMAX] = {
  21. {0x0000, 0x0000, "NULL segment", 0, 0},
  22. {0x0001, 0x0001, "text", 2, 0},
  23. {0x0002, 0x0002, "data", 2, 0},
  24. {0x0003, 0x0003, "comment(ignored)", 0, 0},
  25. {0x0004, 0x0005, "comment(kept)", 2, 0},
  26. {0x0006, 0x0007, "debug information", 2, 0},
  27. {0x0008, 0x001F, "reserved(general extensions)", 1, 0},
  28. {0x0020, 0x0FFF, "reserved(MOSCOW)", 1, 0},
  29. {0x1000, 0x7FFF, "reserved(system dependant)", 1, 0},
  30. {0x8000, 0xFFFE, "reserved(other)", 1, 0},
  31. {0xFFFF, 0xFFFF, "invalid segment", 0, 0}
  32. };
  33. #define getsegconfig(target,number) \
  34. { \
  35. int _i; \
  36. int _t = number; \
  37. for (_i = 0; _i < SEGCONFIGMAX; _i++) \
  38. if (_t >= sconft[_i].typelow && _t <= sconft[_i].typehi) \
  39. { \
  40. target = sconft[_i]; \
  41. if (target.mergetype == 0) target.mergetype = _t; \
  42. break; \
  43. } \
  44. if (_i == SEGCONFIGMAX) \
  45. { \
  46. fprintf(stderr, "PANIC: can't find segment %04X in segconfig\n",\
  47. _t); \
  48. exit(1); \
  49. } \
  50. }
  51. #endif