Analyzing ELF memory layout - elf

I was analyzing an ELF Executable with readelf and getting the following Program and header.
|Type | Offset | VirtAddr | PhysAddr | FileSiz | MemSiz | Flg | Align | size | start addr | end addr |
|PHDR | 0x000034 | 0x08048034 | 0x08048034 | 0x00120 | 0x00120 | R E | 0x4 | 288 | 52 | 340 |
|INTERP | 0x000154 | 0x08048154 | 0x08048154 | 0x00013 | 0x00013 | R | 0x1 | 19 | 340 | 359 |
|LOAD | 0x000000 | 0x08048000 | 0x08048000 | 0x00600 | 0x00600 | RE | 0x1000 | 1536 | 0 | 1536 |
|LOAD | 0x000f0c | 0x08049f0c | 0x08049f0c | 0x0010c | 0x00114 | RW | 0x1000 | 276 | 3852 | 4128 |
|DYNAMIC | 0x000f14 | 0x08049f14 | 0x08049f14 | 0x000e8 | 0x000e8 | RW | 0x4 | 232 | 3860 | 4092 |
|NOTE | 0x000168 | 0x08048168 | 0x08048168 | 0x00044 | 0x00044 | R | 0x4 | 68 | 360 | 428 |
|GNU_EH_FRAME | 0x0004c4 | 0x080484c4 | 0x080484c4 | 0x0003c | 0x0003c | R | 0x4 | 60 | 1220 | 1280 |
|GNU_STACK | 0x000000 | 0x00000000 | 0x00000000 | 0x00000 | 0x00000 | RW | 0x10 | | | |
|GNU_RELRO | 0x000f0c | 0x08049f0c | 0x08049f0c | 0x000f4 | 0x000f4 | R | 0x1 | 244 | 3852 | 4096 |
1). Why is GNU_STACK at Program header table doesn't have a size or start addr?
2). At layout why memory position from 1536 to 3852 (2316 bytes) have no information? What this space is used for?
3). What changes to this format are needed to add extra text section?

Related

SQL: FIter rows with specyfic pattern

I'm a bit new in sql.
I have the following table:
+-----+---------+------------------------+
| ID | ID_TEST | FILE_PATH |
+-----+---------+------------------------+
| 575 | 3 | Landscapes_001_h_A.jpg |
| 576 | 3 | Landscapes_001_h_B.jpg |
| 577 | 3 | Landscapes_001_h_C.jpg |
| 578 | 3 | Landscapes_001_h_D.jpg |
| 579 | 3 | Landscapes_001_h_E.jpg |
| 580 | 3 | Landscapes_002_h_A.jpg |
| 581 | 3 | Landscapes_002_h_B.jpg |
| 582 | 3 | Landscapes_002_h_C.jpg |
| 583 | 3 | Landscapes_002_h_D.jpg |
| 584 | 3 | Landscapes_002_h_E.jpg |
+-----+---------+------------------------+
The pattern for picture is Landscapes_XXX_h_Y.jpg
where
XXX is number from 1 to 185 and Y is quality version from A to E
I wanna select each image name with different quality.
The output should be
+-----+---------+------------------------+
| ID | ID_TEST | FILE_PATH |
+-----+---------+------------------------+
| 575 | 3 | Landscapes_001_h_A.jpg |
| 576 | 3 | Landscapes_002_h_E.jpg |
| 577 | 3 | Landscapes_003_h_C.jpg |
| 578 | 3 | Landscapes_004_h_B.jpg |
| 579 | 3 | Landscapes_005_h_D.jpg |
| 580 | 3 | Landscapes_006_h_A.jpg |
| 581 | 3 | Landscapes_007_h_E.jpg |
| 582 | 3 | Landscapes_008_h_C.jpg |
| 583 | 3 | Landscapes_009_h_B.jpg |
| 584 | 3 | Landscapes_010_h_E.jpg |
+-----+---------+------------------------+
but of course for 185 elements.
I'm using 5.5.60-MariaDB.
How to write SELECT statement? Using REGEXP?

Error converting data type nvarchar to numeric but I have no idea why

I ran a query I created but I am getting an "Error converting data type nvarchar to numeric" error along with "Warning: Null value is eliminated by an aggregate or other SET operation." but I have no idea why as I am not converting anything.
Here is my query:
SELECT DISTINCT TOP 1000
O.Date_Entered
,O.Company_Code
,O.Division_Code
,O.Customer_Purchase_Order_Number
,O.Control_Number
,O.Customer_Number
,P.PickTicket_Number
,sh.PACKSLIP
,Accellos_Download
,Accellos_Allocated
,Accellos_Waved
,Accellos_Label
,Accellos_Last_Pick
,Accellos_Rating
,Accellos_Shipped
,Accellos_Upload
FROM [JMNYC-AMTDB].[AMTPLUS].[dbo].Orders o (nolock)
LEFT JOIN [JMNYC-AMTDB].[AMTPLUS].[dbo].PickTickets P (nolock)
on O.Company_Code = P.Company_Code
and O.Division_Code = P.Division_Code
and O.Control_Number = P.Control_Number
LEFT JOIN [JMDNJ-ACCELSQL].[A1WAREHOUSE].[dbo].SHIPHIST sh (nolock) ON o.Customer_Purchase_Order_Number = sh.cust_po
LEFT JOIN (
SELECT
Packslip
,max( case when Action like 'DNLOAD' then Date_Time end) as Accellos_Download
,max( case when Action like 'ALLOC' then Date_Time end) as Accellos_Allocated
,max( case when Action like 'WAVEORDER' then Date_Time end) as Accellos_Waved
,max( case when Action like 'NEWLABEL' then Date_Time end) as Accellos_Label
,max( case when Action like 'EOL_LSTP' then Date_Time end) as Accellos_Last_Pick
,max( case when Action like 'RATED' then Date_Time end) as Accellos_Rating
,max( case when Action like 'SHIPPED' then Date_Time end) as Accellos_Shipped
,max( case when Action like 'UPLOAD' then Date_Time end) as Accellos_Upload
FROM(
SELECT DISTINCT
Packslip
,Date_Time
,Action
from [JMDNJ-ACCELSQL].[A1Warehouse].[dbo].[RF_LOG2] RL (nolock)
)RLTS
group by Packslip
)RLTSS on Coalesce(sh.PACKSLIP, P.pickticket_number) = RLTSS.PACKSLIP
Here is a sample of the RF_LOG2 Table
+--------------------------------------+----------+----------+---------------------------------------------------------------------------------------------------------+--------+----------+----------+----------+----------+-----------+---------------------+----------------------+----------------------+--------------------+------------+----------+--------+--------+----------+------------------+------------+----------+----------+
| ROWID | PACKSLIP | BINLABEL | EXTENDED | TERMID | USERID | ACTION | QUANTITY | Q_SCALER | TOTLABEL | REFERENCE2 | REFERENCE3 | DATE_TIME | DATE_CREAT | CLIENTNAME | TENANTID | PO_NUM | SERIAL | LOCATION | LICENSE_PLATE | PURGE_FLAG | PACKSIZE | UPLOADED |
+--------------------------------------+----------+----------+---------------------------------------------------------------------------------------------------------+--------+----------+----------+----------+----------+-----------+---------------------+----------------------+----------------------+--------------------+------------+----------+--------+--------+----------+------------------+------------+----------+----------+
| BC5A92B0-F347-4E27-80C5-49798E1B6B75 | 90214801 | PICK | | 0 | | DNLOAD | 0.000000 | 0 | | E. Keith DuBose | l:1 u:1 | 20190726 13:15:29.87 | 0x00000000207E9F1E | 09 | | | | | | 1 | 1.000000 | 0 |
| 3564B24F-1AA9-42A4-83A4-D14151395CED | 90214801 | | | 0 | jsac | ALLOCORD | 0.000000 | 0 | | Allocated | READY TO WAVE | 20190726 13:25:54.51 | 0x00000000207E4672 | 09 | | | | | | 1 | 1.000000 | 0 |
| 0E5B3952-2BD4-4035-A645-1C024B8D3F10 | 90214801 | | | 0 | jsac | ALLOC | 0.000000 | 0 | | Release SWOG | | 20190726 13:25:54.54 | 0x00000000207F14C6 | 09 | | | | | | 1 | 1.000000 | 0 |
| 09575559-EB27-4CDB-8B35-56F741F779E1 | 90214801 | | | 0 | jsac | WAVEORDR | 0.000000 | 0 | | Wave:2392 | RF Picking | 20190726 15:05:31.71 | 0x00000000207EFE60 | 09 | | | | | | 1 | 1.000000 | 0 |
| 61B21B11-D638-4AA2-A94A-25B54650EBAD | 90214801 | | | 0 | | EOL_PRNT | 0.000000 | 0 | | New Carton | 00008139850296299650 | 20190726 15:06:03.79 | 0x00000000207E5A7D | 09 | | | | | | 1 | 1.000000 | 0 |
| 7B46FD91-A30D-4D92-A9E9-6024630D2710 | 90214801 | | | 0 | RFBASE | NEWLABEL | 0.000000 | 0 | 109629965 | 029629965 | | 20190726 15:06:03.80 | 0x00000000207E480E | 09 | | | | | | 1 | 1.000000 | 0 |
| 042D7D42-1D08-4926-AF5B-005868924302 | 90214801 | 3F88082A | 910B2307NSZ99000 /09 | 0 | LSAB | PICK_LP | 1.000000 | 1 | 109629965 | LP picking | | 20190726 15:55:58.92 | 0x00000000207F04F4 | 09 | | | | | 910B2307NSZ99000 | 1 | 1.000000 | 0 |
| 21711DE4-6119-47C0-B3F0-1A0AB816A679 | 90214801 | 3F88082A | 910B2307NSZ99000 /09 | 0 | LSAB | MOVE-OUT | 1.000000 | -1 | | 1 Packs of 1.000000 | via PICKING | 20190726 15:55:58.94 | 0x00000000207E32CC | 09 | | | | | | 1 | 1.000000 | 0 |
| E0D5C819-DC3C-4E21-9857-25476432A057 | 90214801 | 3F88082A | 910B2307NSZ99000 /09 | 0 | LSAB | PICKDETL | 1.000000 | -1 | 109629965 | | | 20190726 15:55:58.95 | 0x00000000207E239A | 09 | | | | | | 1 | 1.000000 | 0 |
| 20D981C1-CE83-459F-9D7A-1784CC215856 | 90214801 | | | 0 | LSAB | EOL_LSCP | 0.000000 | 0 | | Last Pick In Carton | 00008139850296299650 | 20190726 15:55:58.97 | 0x00000000207E07FE | 09 | | | | | | 1 | 1.000000 | 0 |
| CDBCBD5B-9DC7-4FE5-91C9-7C409EA4C2D9 | 90214801 | | | 0 | LSAB | PICKORDR | 0.000000 | 0 | | | | 20190726 15:55:58.97 | 0x00000000207F1CEE | 09 | | | | | | 1 | 1.000000 | 0 |
| DD637317-640E-4A8D-A8DB-9C2C587BA217 | 90214801 | 3F88082A | 910B2307NSZ99000 /09 | 0 | LSAB | PICKLINE | 1.000000 | -1 | | 1 | | 20190726 15:55:58.97 | 0x00000000207E8F55 | 09 | | | | | | 1 | 1.000000 | 0 |
| EE4D734C-8CCE-4C73-B133-C024D79A6054 | 90214801 | | | 0 | LSAB | EOL_LSTP | 0.000000 | 0 | | LAST PICK COMPLETED | 2 | 20190726 15:55:58.97 | 0x00000000207F516E | 09 | | | | | | 1 | 1.000000 | 0 |
| 06204BC1-87B1-4340-9712-C8996388B550 | 90214801 | | | 0 | BACKGRND | RATED | 0.000000 | 0 | 109629965 | 109629965 ACT99 | SHP1563345 | 20190729 08:30:39.86 | 0x000000002089F080 | 09 | | | | | | 1 | 1.000000 | 0 |
| 48759371-8B78-4901-8BE4-749FA55E1D40 | 90214801 | | | 0 | BACKGRND | EOL_SSYS | 0.000000 | 0 | | ShipSys Confirm | | 20190729 08:30:39.89 | 0x0000000020896EF1 | 09 | | | | | | 1 | 1.000000 | 0 |
| 904BF8C6-794D-4288-A594-22BA93A31095 | 90214801 | | | 0 | BACKGRND | SHIPPED | 0.000000 | 0 | | USPS PM | SHP1563345 | 20190729 08:30:39.90 | 0x000000002087F9F3 | 09 | | | | | | 1 | 1.000000 | 0 |
| ECA102C8-B7C4-46D3-A844-FBD0CFE79413 | 90214801 | | | 0 | sdob | SUSPEND | 0.000000 | 0 | | | | 20190729 09:45:40.12 | 0x00000000208922D8 | 09 | | | | | | 1 | 1.000000 | 0 |
| 867A7B87-5AB2-4EE7-8FDC-7175D406C0F0 | 90214801 | | | 0 | sdob | UNSUSPND | 0.000000 | 0 | | | | 20190729 10:07:56.88 | 0x00000000208A0AF5 | 09 | | | | | | 1 | 1.000000 | 0 |
| E5FB157B-9837-4DA8-B5D0-9A605603FD60 | 90214801 | | | 0 | sdob | SHIPCOMP | 0.000000 | 0 | | | ship_order() | 20190729 11:42:20.30 | 0x000000002089D1FD | 09 | | | | | | 1 | 1.000000 | 0 |
| 37D4B782-1184-4F91-913B-F1BA251740DF | 90214801 | | | 0 | sdob | SHIPPED | 0.000000 | 0 | | USPS PM | SHP1563345 | 20190729 11:42:20.32 | 0x000000002088482F | 09 | | | | | | 1 | 1.000000 | 0 |
| 4FDE75F7-D98B-451E-A106-0C9F29BADEE1 | 90214801 | | | 0 | sdob | EOL_EXTN | 0.000000 | 0 | | External Process | | 20190729 11:42:20.33 | 0x0000000020897E4A | 09 | | | | | | 1 | 1.000000 | 0 |
| C41D73C8-385A-4547-A684-7CEA1B7CE9DB | 90214801 | PICK | | 0 | C# | UPLOAD | 0.000000 | 0 | | E. Keith DuBose | | 20190729 11:43:45.66 | 0x00000000208A1D2F | | | | | | | 1 | 1.000000 | 0 |
+--------------------------------------+----------+----------+---------------------------------------------------------------------------------------------------------+--------+----------+----------+----------+----------+-----------+---------------------+----------------------+----------------------+--------------------+------------+----------+--------+--------+----------+------------------+------------+----------+----------+
What I am trying to do is to get the timestamp for each part of the order. So when it was created, when it was picked, and so on. I want this information to be displayed horizontally, per order. Also, it only crashed after running for like 5 minutes.
The warning Warning: Null value is eliminated by an aggregate or other SET operation happen because of the value of Date_Time that you do in max() containing NULL value.
For the error, I'm afraid that that causes from Coalesce(sh.PACKSLIP, P.pickticket_number). You should check the type and convert one of them to have the same type as another. From the hint from the table, you attached they both should be the numeric value.
To avoid the warning you can use below option.
SET ANSI_WARNINGS OFF

SQL subcategory total is not properly placed at the end of every parent category

I am having trouble in SQl query,The query result should be like this
+------------+------------+-----+------+-------+--+--+--+
| District | Tehsil | yes | no | Total | | | |
+------------+------------+-----+------+-------+--+--+--+
| ABBOTTABAD | ABBOTTABAD | 377 | 5927 | 6304 | | | |
| ABBOTTABAD | HAVELIAN | 112 | 2276 | 2388 | | | |
| ABBOTTABAD | Overall | 489 | 8203 | 8692 | | | |
| CHARSADDA | CHARSADDA | 289 | 3762 | 4051 | | | |
| CHARSADDA | SHABQADAR | 121 | 1376 | 1497 | | | |
| CHARSADDA | TANGI | 94 | 1703 | 1797 | | | |
| CHARSADDA | Overall | 504 | 6841 | 7345 | | | |
+------------+------------+-----+------+-------+--+--+--+
The overall total should be should be shown at the end of every parent category but now it is showing like this
+------------+------------+-----+------+-------+--+--+--+
| District | Tehsil | yes | no | Total | | | |
+------------+------------+-----+------+-------+--+--+--+
| ABBOTTABAD | ABBOTTABAD | 377 | 5927 | 6304 | | | |
| ABBOTTABAD | HAVELIAN | 112 | 2276 | 2388 | | | |
| ABBOTTABAD | Overall | 489 | 8203 | 8692 | | | |
| CHARSADDA | CHARSADDA | 289 | 3762 | 4051 | | | |
| CHARSADDA | Overall | 504 | 6841 | 7345 | | | |
| CHARSADDA | SHABQADAR | 121 | 1376 | 1497 | | | |
| CHARSADDA | TANGI | 94 | 1703 | 1797 | | | |
+------------+------------+-----+------+-------+--+--+--+
My query is sorting second column with respect to first column although order by query is applied on my first column. This is my query
select District as 'District', tName as 'tehsil',[1] as 'yes',[0] as 'no',ISNULL([1]+[0], 0) as "Total" from
(
select d.Name as 'District',
case when grouping (t.Name)=1 then 'Overall' else t.Name end as tName,
BoundaryWallAvailable,
count(*) as total from School s
INNER JOIN SchoolIndicator i ON (i.refSchoolID=s.SchoolID)
INNER JOIN Tehsil t ON (t.TehsilID=s.refTehsilID)
INNER JOIN district d ON (d.DistrictID=t.refDistrictID)
group by
GROUPING sets((d.Name, BoundaryWallAvailable), (d.Name,t.Name, BoundaryWallAvailable))
) B
PIVOT
(
max(total) for BoundaryWallAvailable in ([1],[0])
) as Pvt
order by District
P.S: BoundaryWall is one column through pivoting i am breaking it into Yes and No Column

How to make sql hive when i have input this?

input:
| a.user_id | a_stream_length | b_stream_length | subtract_inactive |
-----------------------------------------------------------------------------
| a | 11 | 1686 | 22 |
| a | 1686 | 328 | 12 |
| a | 328 | 732 | 22 |
| a | 732 | 11 | 1699 |
| a | 11 | 2123 | 18 |
| a | 2123 | 160 | 2 |
| a | 160 | 1358 | 0 |
| a | 1358 | 129 | 1 |
| a | 129 | 4042 | 109334 |
output:
| a | (1686+11+328+732) (if subtract_inactive < 1000) |
| a | 732(a_stream_length) if subtract_inactive > 1000) |

SQL Server : need to find min/max/count value given time partition and conditional parameters

I have a database containing results from horse races.
For each horse in each race i want to find their previous best time (TOTAL_TIME) given that the parameters was the same as the current race/row (DISTANCE, DIVISION, START_MODE).
I also want to count the number of times the horse won a race before the current/row date
Finally, for each race and horse; I want to RANK the competing horses based on the values calculated in 1 & 2
SELECT b.datum AS RACE_DATE,/*date of race*/
b.id AS RACE_ID,
c.namn AS HORSE_NAME,
a.plac AS PLACEMENT,/*what position the horse finished in*/
a.rank AS RANK_ODDS,
a.tid AS TOTAL_TIME,/*total time it took for horse to finish race*/
b.bana AS TRACK,/*geographical race track*/
b.distans AS DISTANCE,/*short, long, etc.*/
b.division AS DIVISION,/*what type of breed the competition was etc.*/
b.startsatt AS START_MODE /*way of starting the race, car or manual*/
FROM trav.prog a
JOIN trav.tvl b
ON a.tvlid = b.id
JOIN trav.horse c
ON a.horseid = c.id
ORDER BY race_date DESC,
race_id DESC
Sample output: (Thank you kindly for the formatting help)
+------------+---------+------------------+-----------+-----------+------------+-------+----------+----------+------------+
| RACE_DATE | RACE_ID | HORSE_NAME | PLACEMENT | RANK_ODDS | TOTAL_TIME | TRACK | DISTANCE | DIVISION | START_MODE |
+------------+---------+------------------+-----------+-----------+------------+-------+----------+----------+------------+
| 2017-03-28 | 166700 | YANKEE FRECEL* | 9 | 3 | 161 | MO | K | V | A |
| 2017-03-28 | 166700 | ALCYONE LOVE | 3 | 9 | 152 | MO | K | V | A |
| 2017-03-28 | 166700 | GIANT STAR* | 6 | 6 | 155 | MO | K | V | A |
| 2017-03-28 | 166697 | RUBY FRONTLINE | 6 | 11 | 188 | MO | M | U | V |
| 2017-03-28 | 166696 | CAN´T STAND STIL | 4 | 3 | 150 | MO | K | U | A |
| 2017-03-28 | 166696 | MISS MIRCHI* | 3 | 5 | 149 | MO | K | U | A |
| 2017-03-28 | 166695 | LYNLINN* | 4 | 6 | 262 | MO | K | U | A |
| 2017-03-28 | 166695 | SIKVELANDS SVAR | 3 | 1 | 257 | MO | K | U | A |
| 2017-03-28 | 166692 | NOK´EN FRÆKKERT | 1 | 6 | 134 | J | M | V | A |
| 2017-03-28 | 166692 | FLEX LANE | 5 | 4 | 137 | J | M | V | A |
| 2017-03-28 | 166692 | EDWARD ALE* | 4 | 3 | 137 | J | M | V | A |
| 2017-03-28 | 166692 | ATTACK DIABLO | 3 | 1 | 136 | J | M | V | A |
| 2017-03-28 | 166692 | SOLVATO | 2 | 2 | 136 | J | M | V | A |
| 2017-03-28 | 166692 | CALIBER T.T. | 7 | 8 | 140 | J | M | V | A |
| 2017-03-28 | 166692 | KASH´S CANTAB | 6 | 5 | 137 | J | M | V | A |
| 2017-03-28 | 166692 | CAPELLO BOB | 8 | 7 | 142 | J | M | V | A |
| 2017-03-28 | 166691 | WILDINTENTION | 4 | 2 | 125 | J | K | V | A |
| 2017-03-28 | 166691 | MR ARKANSAS | 3 | 10 | 124 | J | K | V | A |
| 2017-03-28 | 166691 | KAMANDA | 7 | 6 | 127 | J | K | V | A |
| 2017-03-28 | 166691 | APOLLO DAMGÅRD* | 6 | 8 | 127 | J | K | V | A |
+------------+---------+------------------+-----------+-----------+------------+-------+----------+----------+------------+